title: InputStream reader blocking thread
body: <p>I wrote this InputStream reader to listen to a Socket. This code is in a <code>while(!stop)</code> loop inside the <code>run</code> method of a thread. This reader blocks the thread, and does not print the message.</p>
  
  <pre><code>int read = 0;
  byte[] buf = new byte[512];
  int index = 0;
  try {
      while (!stop &amp;&amp; (read = in.read()) != -1) {
          System.out.println("read loop");
          buf[index++] = (byte) read;
      }
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>