title: Two clients on a single thread Java
body: <p>I am writing a program in which I have a server that is continuously listening for requests (like most servers). I want it to create a new thread each time I get a client connection(I'm done with this part), and I want it to add the client immediately after it, to the same thread. So I'll have two clients connected to the same thread.</p>
  
  <p>Something along the lines of:</p>
  
  <pre><code>.....
  try(ServerSocket serversocket = new ServerSocket();
      Socket client1 = serversocket.accept();
      Socket client2 = serversocket.accept();){
  
      //spawn new thread with sockets to client1 and client2
  </code></pre>
  
  <p>Is this possible? Are there any alternatives to this? Would it be possible to get two different threads to converse with each other? </p>
  
  <p>Would it be possible to create a new server socket from the thread extending to a client? </p>
  
  <pre><code>...
  try(ServerSocket serversocket = new ServerSocket();
      Socket client1 = serversocket.accept();){
      //spawn thread
  }
  </code></pre>
  
  <p>And now in the thread:</p>
  
  <pre><code>....
  try(ServerSocket serversocket2 = new ServerSocket();
      Socket client2 = serversocket2.accept();){
      //exchange information between two clients and do other stuff
  }
  </code></pre>
  
  <p>Any ideas? All help is greatly appreciated.</p>