📄 usethread.java
字号:
public class UseThread
{ public static void main(String args[ ])
{ myThread th1=new myThread("Thread I");
myThread th2=new myThread("Thread II");
th1.start( );
th2.start( );
}
}
class myThread extends Thread
{ public myThread(String str)
{ super(str);
}
public void run( )
{ for(int I=0;I<3;I++)
{ System.out.println(getName( )+"正在运行!");
try
{ sleep((int)(Math.random( )*1000));
}
catch(InterruptedException e) { }
}
System.out.println(getName( )+"已经结束!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -