我采用的方法是使用
ExecutorService管理线程池。
ExecutorService es = Executors.newCachedThreadPool();for(int i=0;i<5;i++) es.execute(new Runnable() { });es.shutdown();boolean finished = es.awaitTermination(1, TimeUnit.MINUTES);// all tasks have finished or the time has been reached.


