1.

What Is The Difference Between A Countdownlatch And Cyclicbarrier?

Answer»
  • When you are using a CountDownLatch, you specify the number of calls to the COUNTDOWN() method when creating a CountDownLatch object. What this means is you can use CountDownLatch with only a single thread and using countdown() to DECREMENT as and when the specified even occur.

    When you are using CyclicBarrier you specify the number of THREADS that should call await() method in order to TRIP the barrier. That means if you have a CyclicBarrier initialized to 3 that means you should have at least 3 threads to call await().
  • CountDownLatch can't be reused, when count reaches zero it cannot be RESET.

    CyclicBarrier can be reused after the waiting threads are released.



Discussion

No Comment Found