Exchanger
Exchanger is a thread-synchronization construct that lets a pair of threads exchange data items. An exchanger is similar to a cyclic barrier whose count is set to 2 but also supports exchange of data when both threads reach the barrier. Exchanger can be handy in solving Producer Consumer pattern where Producer and consumer threads can exchange their data. The java.util.concurrent.Exchanger<V> class implements an exchanger. This class provides an Exchanger() constructor for initializing an exchanger that describes an exchange point and a pair of exchange() methods for performing an exchange. Exchanger has 2 method exchange (V x ) and V exchange(V x, long timeout, TimeUnit unit) . exchange() method enables two threads to exchange their data between each other in java. If current thread is first one to call exchange() method then it will until one of following things happen: Some other thread calls exchange() method in java, or Some other thread inter...