title: Simple Java Threaded TCP Server thread
body: <pre><code>/*main method*/
  
  Server server = new Server(tcpPort);
  new Thread(server).start();
  
  try {
  
    Thread.sleep(1000*60); /* 60 seconds*/
  } catch (InterruptedException e) {
    e.printStackTrace();
  }
  
  server.stop;
  ...
  </code></pre>
  
  <p>This is the code I've written. A Server thread is started, and runs for 60 seconds. How do I change this to run infinitely, ending when a user enters Enter via a BufferedReader or something.</p>
  
  <p>I've tried it with </p>
  
  <pre><code>while(!input.equals("")) { /* just pseudocoded here...*/
  Thread.sleep(10);   
  }
  </code></pre>
  
  <p>but this will my Server stop from working correctly. My clients won't even connect to it anymore. Have I made a design mistake or is this an easy problem to solve?</p>