📄 threadtest1.java.bak
字号:
class ThreadTest1{
public static void main(String args[]) {
/*下面两个语句用于输出提示信息*/
System.out.println("This an example about creating thread by inheriting from Thread class.");
/*启动名为“Jon”的线程*/
new SubThread("Jon").start();
}
}
/*类SubThread是Thread的子类,在该类中,通过run()方法输出正在运行的线程的名称*/
class SubThread extends Thread {
/*构造方法生成一个名称为str的线程对象*/
public SubThread(String str) {
super(str);
}
/*run()方法输出正在运行的线程名称*/
public void run() {
System.out.println("Thread "+getName() + ": " + "running!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -