CountDownLatchUtil { public void useCountDownLatch(){ long beginTime=System.currentTimeMillis(); int threadSize=20; CountDownLatch countDownLatch=new CountDownLatch(threadSize); try { for (int i = 0; i <threadSize ; i++) { startThread("子线程"+i,countDownLatch); } countDownLatch.await(); mainMethod(beginTime); } catch (InterruptedException e) { e.printStackTrace(); } }  static void main(String[] args); void useCountDownLatch();  }
@Test public void testUseCountDownLatch() throws Exception { new CountDownLatchUtil().useCountDownLatch(); }