<img alt="" src="https://secure.leadforensics.com/150446.png " style="display:none;">


Synchronizers In Java - CyclicBarrier

Along with CountDownLatch, FutureTask and Semaphore, the Concurrency API in Java 5 also introduced a barrier – CyclicBarrier. This class is used as a barrier for a set of threads, to keep them waiting until all the threads have reached it. Once all the threads reach the barrier, it is tripped, allowing them to perform further execution. The number of threads in WAITING state, which when reached should trip the barrier, is passed as an argument to the constructor of CyclicBarrier. A Runnable action to be performed when the barrier is tripped can also be defined optionally while instantiating CyclicBarrier. The last thread to enter the barrier executes this action before the other waiting threads are released. If the action throws exception, the barrier is broken and all the other threads receive a checked exception BrokenBarrierException.

Topics: CyclicBarrier Java Multithreading Concurrency API Technology synchronizers

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.