How does the class Exchanger in Java actually work?

38 views Asked by At

I'm still very new to how Threads work in Java and I got an assignment to recreate the Exchanger class based on its functionality.

I read the documentation and I understand what it is supposed to do, but I'm still confused about how it actually works:

Whenever exchange gets called, how does it actually make the trade between threads?

  1. Does it put the object from its parameter in some sort of stack and returns another one that was already previously put in that stack?
  2. Where would that stack come from?

Thank you for your help!

0

There are 0 answers