CyclicBarrier Class Flashcards
Constructor that creates a CyclicBarrier object with the number of threads waiting on it specified. Throws IllegalArgumentException if numThreads is negative or zero.
CyclicBarrier(int numThreads)
Same as CyclicBarrier(int numThreads), additionaly takes the thread to call when the barrier is reached.
CyclicBarrier(int parties, Runnable barrierAction)
Blocks until the specified number of threads have called await() on this barrier. The method returns the arrival index of this thread. Has an overloaded version that takes a time-out period as an additional option. It throws a TimeoutException if all other threads aren’t reached within the time-out period.
int await()
Returns true if the barrier is broken. A barrier is broken if at least one thread in that barrier was interrupted or timed-out, or if a barrier action failed throwing an exception.
boolean isBroken()
Resets the barrier to the initial state. If any threads are waiting on that barrier, they will throw the BrokenBarrier exception.
void reset()