join方法
join():当前线程等待子线程终止
class MyThread implements Runnable { public void run() { int i = 0; while(i < 100) { System.out.println(Thread.currentThread() + " a = " + i); i++; Thread.yield(); } } } public class Demo1 { public static void main(String[] args) throws Exception { Thread t1 = new Thread(new MyThread(),"t1"); t1.start(); t1.join(1); System.out.println(Thread.currentThread()+ "tttttttttttttt"); }