读书人

What is CountDownLatch

发布时间: 2013-08-01 15:23:18 作者: rapoo

What is CountDownLatch?

CountDownLatch was?introduced with JDK 1.5 along with other concurrent utilities like CyclicBarrier, Semaphore,?ConcurrentHashMap?and?BlockingQueue?in java.util.concurrent package. This class?enables a java thread to wait until other set of threads completes?their tasks. e.g. Application’s main thread want to wait, till other service threads which are responsible for starting framework services have completed started all services.

CountDownLatch works by having a counter initialized with number of threads, which is decremented each time a thread complete its execution. When count reaches to zero, it means all threads have completed their execution, and thread waiting on latch resume the execution.

What is CountDownLatch

读书人网 >软件架构设计

热点推荐