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)?

    1 answer 1

    There are a lot of ways to transfer data. Consider the Pipe class from the java.nio package. This class is a set of internal abstract classes and a couple of methods that in total make it possible to work with a certain channel for unidirectional transmission of bits. At the moment of the start of transmission, the source is blocked. the fastest way to work between threads.

    This is just one of the ways it is possible to realize the exchange of data ... There are still possibilities of your own implementation through synchronized stacks or ready-made BlockingQueue or Exchanger in general, the choice is yours