/*
* Join:
* 当A线程执行到了B线程的.join()方法时,A就会等待。等B线程都执行完才会执行。
*
* join可以用来临时加入线程执行
*/
package test.itheima;
public class JoinDemo {
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
JoinDemo1 d=new JoinDemo1();
Thread t1=new Thread(d);
Thread t2=new Thread(d);
t1.start();
t1.join();
t2.start();
for(int x=0;x<10000;x++){
System.out.println(Thread.currentThread().getName()+"..."+x);
}
System.out.println("over.");
}
}
class JoinDemo1 implements Runnable{
public void run(){
for(int x=0;x<10000;x++){
System.out.println(Thread.currentThread().getName()+"..."+x);
}
}
}