PDA

View Full Version : What is difference between CyclicBarriar and Countdown Latch in Java ?



sulbha
01-03-2018, 12:23 AM
What is difference between CyclicBarriar and Countdown Latch in Java ?

jackar56
01-05-2018, 01:51 AM
Though I am not a Java expert (not even a Java programer), I am seeing that nobody has answered this question and hence I am going to make an attempt.

Both are to do with multi-threads.

Count Down latch is when one or more threads have to wait till some actions take place in OTHER threads and at that point, the threads are released. (e.g. when a group of friends are involved in managing an event and can decide on their own, the person assigned for invitations and the transport has to wait for the friend who has to fix the event hall.)

Cyclic Barrier is similar to Count Down latch in the sense that the threads are made to wait but there is a chance of repetion. For example, the boss of the event management company, from the above example, may look at the expenses for hall, invitation and the transport and may ask them to repeat the exercise to optimize things.

Java Experts may point ouf it I am right. Till then, use the answer at your own risk.