The java.util.concurrent package contains several classes that help manage a set of collaborating threads—see Table 1-3. These mechanisms have “canned functionality” for common rendezvous patterns between threads. If you have a set of collaborating threads that follows one of these behavior patterns, you should simply reuse the appropriate library class instead of trying to come up with a handcrafted collection of locks.
|Class||What It Does||When To Use|
|CyclicBarrier||Allows a set of threads to wait until a predefined count of them has reached a common barrier, and then optionally executes a barrier action.||When a number of threads need to complete before their results can be used.|
|CountDownLatch||Allows a set of threads ...|