InterviewSolution
| 1. |
What is CyclicBarrier and CountDownLatch? |
|
Answer» 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. |
|