public class ThreadJoin {
public static void main(String[]args) throws InterruptedException{
DemoThread t0 =new DemoThread();
DemoThread t1 =new DemoThread();
DemoThread t2 =new DemoThread();
t0.start();
t0.join();
t1.start();
t2.start();
}
}
class DemoThread extends Thread{
public void run(){
for(int i =0 ;i <5 ;i++){
System.out.println(this.getName()+":"+i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}