1.main线程中先调用threadA.join() ,再调用threadB.join()实现A->B->main线程的执行顺序 调用threadA.join()时,main线程会挂起,等待threadA执行完毕返回后再执行,到执行threadB.join()时再挂起,待threadB执行完毕返回继续执行main 使用场景:线程B依赖线程A的计算结果的场景 package concurrency; public class JoinTest { public static void main(
方法一: Thread.join()方法,亲测可行,thread.join()方法 Vector<Thread> ts = new Vector<Thread>(); for (int i = 0; i < 200; i++) { Thread t = new Thread(new Runnable() { @Override public void run() { Counter.inc(); } }); ts.add(t); t.start(); } for (Threa