Google News
logo
Java Multithreading - Interview Questions
What is CyclicBarrier and CountDownLatch?
CyclicBarrier and CountDownLatch, both are required for managing multithreaded programming. But there is some difference between them as given below : 
 
CyclicBarrier : It is a tool to synchronize threads processing using some algorithm. It enables a set of threads to wait for each other till they reach a common execution point or common barrier points, and then let them further continue execution. One can reuse the same CyclicBarrier even if the barrier is broken by setting it. 
 
CountDownLatch : It is a tool that enables main threads to wait until mandatory operations are performed and completed by other threads. In simple words, it makes sure that a thread waits until the execution in another thread completes before it starts its execution. One cannot reuse the same CountDownLatch once the count reaches 0.
Advertisement