I was reading through the java.util.concurrent API, and found that
CountDownLatch
: A synchronization aid that allows one or more threads to wait
One point that nobody has yet mentioned is that, in a CyclicBarrier
, if a thread has a problem (timeout, interrupted...), all the others that have reached await()
get an exception. See Javadoc:
The CyclicBarrier uses an all-or-none breakage model for failed synchronization attempts: If a thread leaves a barrier point prematurely because of interruption, failure, or timeout, all other threads waiting at that barrier point will also leave abnormally via BrokenBarrierException (or InterruptedException if they too were interrupted at about the same time).