[Java - Synchronization] Latches

1) Countdown Latch

A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes.

A CountDownLatch is initialized with a given count. The await method is blocked until the current count reaches zero; we can reduce current count using the method, countDown().
The count cannot be reset. 

2) Cyclic Barrier

Similar to countdown latch, but the count can reset.


Resources

Comments

Popular posts from this blog

[Redis] Redis Cluster vs Redis Sentinel

[Unit Testing] Test Doubles (Stubs, Mocks....etc)

[Node.js] Pending HTTP requests lead to unresponsive nodeJS