📄 testsubthread2.java
字号:
package Thread;
public class TestSubThread2
{
public static void main(String []args) throws InterruptedException
{
SubThread t1=new SubThread("First ");
SubThread t2=new SubThread("Second ");
SubThread t3=new SubThread("Third ");
t1.start();
//Thread.sleep(500);
try
{
t1.join();
}
catch(InterruptedException e)
{
System.out.println(e.toString());
}
t2.start();
t3.start();
System.out.println(" 叱痰 t1 校 main() 希");
}
}
class SubThread extends Thread
{
String str;
public SubThread(String s)
{
super(s);
}
public void run()
{
for(int i=1;i<8;i++)
{
try
{
sleep((int)(Math.random()*100));
}
catch(InterruptedException e)
{
System.out.println(e.toString());
}
//for(long j=1;j<100000000;j++);
System.out.println(getName()+" "+i+" !");
}
System.out.println(getName()+" end: !");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -