Rabu, 11 November 2020

How to use Exchanger for sharing Object between Threads in Java [Example]

Hello guys, if you are working in a concurrent Java application then you might have heard about the Exchanger class of java.util.concurrent package. The Exchanger in Java is another concurrency or synchronization utility introduced in Java 1.5 along with CountDownLatch, CyclicBarrier, and Semaphores. As the name suggests, the Exchanger allows two Threads to meet and exchange data at the rendezvous or meeting point. This means you can use Exchanger to share objects between threads and for inter-thread communication. The java.util.Exchanger is a parametric class, which defines and holds the type of object to be exchanged. It has an overloaded method called the exchange(), which is used to exchange objects between threads.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon