Exchanges class is used when two threads can exchange objects.
I can see in most of example, two threads are started with exchanger object as argument and Exchange is called thereby.
Exchanger exchanger = new Exchanger();
ExchangerRunnable exchangerRunnable1 =
new ExchangerRunnable(exchanger, "A");
ExchangerRunnable exchangerRunnable2 =
new ExchangerRunnable(exchanger, "B");
new Thread(exchangerRunnable1).start();
new Thread(exchangerRunnable2).start();
What are real time situations when this requirement arise during Multithreading? Shall Exchanger class be always used in all cases in Multithreaded project to make project scalable?
Note: There is one example found on Google that Producer and consumer may exchange buffers. Not sure how much practical it is. What other practical situations can be so that project can be architect accordingly.Another example is picked from Java documentation but no details are provided