There is a socket server. Two clients are connected to it via a socket connection. How to organize communication between threads (how to transfer data or call a method in another thread)?
There are many ways to transfer data, as an option, consider the Pipe class from the java.nio package This class is a set of internal abstract classes and a couple of methods that together make it possible to work with a certain channel for unidirectional bit transmission. At the moment of transmission, the source stream is blocked. This is one of fastest ways to work between threads.
This is just one of the ways it is possible to implement data exchange … There are also possibilities of your own implementation through synchronized stacks or ready-made BlockingQueue or Exchanger, in general, the choice is yours