InterviewSolution
| 1. |
What Is Countdownlatch In Java Concurrency? |
|
Answer» CountDownLatch can be visualized as a latch that is released only after the given number of events occur. CountDownLatch is initialized with that count (given number of events). Each time one of those events occur count is decremented, for that COUNTDOWN() method is USED. Thread(s) that are waiting for the latch to release (current count reaches zero due to invocations of the countDown()method) are blocked USING await() method. It is useful in the SCENARIO when you WANT one or more threads to wait until one or more events being performed in other threads complete. CountDownLatch can be visualized as a latch that is released only after the given number of events occur. CountDownLatch is initialized with that count (given number of events). Each time one of those events occur count is decremented, for that countdown() method is used. Thread(s) that are waiting for the latch to release (current count reaches zero due to invocations of the countDown()method) are blocked using await() method. It is useful in the scenario when you want one or more threads to wait until one or more events being performed in other threads complete. |
|