title: Java socket server without using threads
body: <p>I am working on a application which should be very light weight and use minimum number of threads. <br>
  I need a socket server in my application for heartbeat monitor.<br></p>
  
  <pre><code>ServerSocket listener= new ServerSocket(port);
  while (true) {
     Socket socket = listener.accept();
  
     Runnable thread = new HBClient(this, socket);
     thread.run();
  }
  </code></pre>
  
  <p>Problem here is I have to use one thread per one client.<br>
  Is there a way to do this without using threads? Maybe an event driven approach to identify when a client is connected or a non blocking method to accept clients.(I already checked java.nio but it seems even that cannot be used without threads)</p>