1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Integer taskCount =700;
final CountDownLatch begin =new CountDownLatch(1); final ExecutorService exec =Executors.newFixedThreadPool(taskCount); for (int index =0; index < taskCount; index++){ final int NO= index +1; Runnable run =new Runnable() { @Override public void run() { try { begin.await(); }catch (InterruptedException e){ e.printStackTrace(); }finally { } } }; exec.submit(run); } System.out.println("开始执行");
begin.countDown();
exec.shutdown();
|