JavaAdvanced#concurrency

What is a CountDownLatch?

A synchronization aid that lets one or more threads wait until a set of operations in other threads completes, implemented by counting down from an initial value; once it hits zero, waiting threads proceed.

Example
CountDownLatch latch = new CountDownLatch(3);
// each worker thread calls latch.countDown() when done
latch.await(); // main thread blocks until count reaches 0

Related Questions

1
JavaAdvanced#concurrency

What is a ThreadLocal and when would you use it?

Open
2
JavaIntermediate#concurrency

What is the difference between Thread.sleep() and Object.wait()?

Open
3
JavaAdvanced#concurrency

What is the difference between ReentrantLock and synchronized?

Open