2. CountDownLatch Example
How to use?
1. new CountDownLatch with count
number
2. Pass CountDownLatch instance to
many threads for doing something
and counting down
3. Pass CountDownLatch instance to
one or many threads to wait for
counting down to zero
4. Thread will keep running after
counting down to zero
6. Phaser
1. Register for each threads
2. Call arrive if job of current phase
finish
3. Call arriveAndAwaitAdvance if
you need wait for everyone
finished
4. Whenever all registered Phaser
arrived, phase will advance and
onAdvance method will be
called
10. Semaphore
Number of permits to be acquired or released.
1. acquire: grab permit(s), wait until all available
2. tryAcquire: grab permit(s) until given timeout
3. release: release permit(s)
4. drainPermits: grab ALL permits
5. availablePermits: get current available permits count
Reference: Semaphore.java