java.util.concurrent · java.base · since Java 1.5
CountDownLatch
public class CountDownLatchOne-shot gate: await() blocks until countDown() has been called N times. Start gates, completion gates, and "wait for N services to boot".
- Single-use: it cannot be reset (CyclicBarrier and Phaser can)
Key methods
CountDownLatch(int count) | The number of events to wait for. |
void await() / boolean await(timeout, unit) | Block until zero. |
void countDown() | Record one event — never blocks. |