Friday, 8 April 2016

How CountDownLatch works ?


CountDownLatch
  • allows one or more threads to wait for a set of events to occur
  • A type of Synchronizer
  • initializes a counter - A number of events to wait for
  • has a countdown method, which decrements the counter - indicates an event has occurred
  • has an await method, which waits for counter to reach 0 - indicates all events have occurred

await method blocks until the counter reaches 0
During the block, waiting thread is interrupted or times out.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.