* public final void join()throws InterruptedException
* 等待该线程终止
public class ThreadJoinDemo {
public static void main(String[] args) {
//创建线程类对象
ThreadJoin j1=new ThreadJoin();
ThreadJoin j2=new ThreadJoin();
ThreadJoin j3=new ThreadJoin();
j1.setName("hello");
j2.setName("world");
j3.setName("java");
//启动线程
j1.start();
//设置j2的等待线程终止
try {
j1.join();//需要将j1执行完毕后面的才能进来(其实线程安全的同步方法:加同步锁)
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
j2.start();
j3.start();
}
}
public class ThreadJoin extends Thread {
@Override
public void run() {
for(int x=0;x<100;x++) {
System.out.println(this.getName()+" "+x);
}
}
}



