可能的重复:
ExecutorService,如何等待所有任务完成
Java ExecutorService:awaitTermination 所有递归创建的任务
有没有办法阻止当前线程直到ExecutorService
完成所有任务?
executor.execute(task1);
executor.execute(task2);
executor.execute(task3);
executor.execute(task4);
executor.execute(task5);
// ...now I want to block until all tasks have finished executing...
System.out.println("done!")