java多線程等待計數器

final CountDownLatch latch = new CountDownLatch(1);// 多線程等待計數器
latch.countDown();  //在子線程中減少計數器
try {
   latch.await();//等待countDown所有完成後,執行後面的代碼
} catch (InterruptedException e) {
   e.printStackTrace();
}
相關文章
相關標籤/搜索