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

Synchronizers In Java - CountDownLatch

The Concurrency API introduced in Java 5 provides a latch – CountDownLatch. A latch is a synchronizer which acts like a gate. CountDownLatch acts like a one-time closed gate which is initially closed and can be opened only once. Once it is opened it will remain open.

Topics: synchronizer Java ExecutorService Multithreading latch Concurrency API CountDownLatch Technology synchronizers

e-Zest Solutions is digital experience engineering company with facilities in the United States (Detroit & San Jose), Germany (Hannover), United Kingdom (London UK) and India (Pune) with global clientele. Our services include custom software development, offshore software development, UX consulting, BigData, Managed cloud Services (Azure & AWS), SharePoint consulting/Migration, Enterprise Java application development, Automated software testing services.