Skip to main content

Explain CountDownLatch, CyclicBarrier, and Semaphore.

Senior Java
Quick Answer CountDownLatch: one-time gate - await() blocks until count reaches zero. Used to wait for N tasks to complete. CyclicBarrier: reusable rendezvous - await() blocks until N threads all arrive, then all proceed together. Used for parallel computation phases. Semaphore: limits N concurrent accesses to a resource. acquire() blocks if permits exhausted, release() returns a permit. All are in java.util.concurrent.

Answer

CountDownLatch waits for a set of threads to finish.
CyclicBarrier allows threads to wait for each other repeatedly.
Semaphore controls access to limited resources using permits.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice