Make delicious recipes!

CyclicBarrier

A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other.


The barrier is called cyclic because it can be re-used after the waiting threads are released.


A CyclicBarrier supports an optional Runnable command that is run once per barrier point, after the last thread in the party arrives, but before any threads are released. This barrier action is useful for updating shared-state before any of the parties continue.


Example:


So, a Cyclic-Barrier (CB) is different from Count-Down-Latch (CDL) in 2 ways:

  1. It has a barrier-action thread to run when all threads reach waiting state.

  2. It can be reused after all threads have reached waiting state once.




Like us on Facebook to remain in touch
with the latest in technology and tutorials!


Got a thought to share or found a
bug in the code?
We'd love to hear from you:

Name:
Email: (Your email is not shared with anybody)
Comment:

Facebook comments:

Site Owner: Sachin Goyal