Sunday, August 30, 2015

Countdown latches: concurrency

Countdown latches are concurrency construct that cause one or more thread to wait until a set of thread execution completes

Using Countdown Latches:

A main thread creates a countdown Latch, that we can use as a starting gate to start all thread simultaneously
Main thread decrement this latch to let all workers proceed.

-Main thread waits for another countdown latch initialised with number of worker thread 
-When all worker threads completes, it decrease the countdown and when it reaches zero the main /waiting thread proceeds and gather results

No comments:

Post a Comment