Say you entered the golf store hoping to find a four,
When you queue to get time from one of the store sellers, you proshopVendorSemaphore.acquire() called proshopVendorSemaphore.acquire() , as soon as you get the tee time, you called proshopVendorSemaphore.release() . Note: any of the free operators can serve you, i.e. shared resource.
Now you come to the starter, it starts CountDownLatch(4) and calls await() to wait for others, for your part you called check-in, i.e. CountDownLatch . countDown() , as well as the rest of foursome. When everyone arrives, the starter gives ahead ( await() returns the call)
Now, after nine holes, when each of you takes a break, hypothetically allows you to use the starter again, he uses the βnewβ CountDownLatch(4) to disable Hole 10, the same wait / sync as hole 1.
However, if the starter used a CyclicBarrier to start, it could have reset the same instance in Hole 10 instead of the second latch that they use and throw.
Raj Srinivas Aug 01 '13 at 22:16 2013-08-01 22:16
source share