title: Block without spinning in Java?
body: <p>Certain methods in Java will block until they can do something, like ServerSocket.accept() and InputStream.read(), but how it does this is not easy for me to find. The closest thing I can think of is a while() loop with a Thread.sleep() each time through, but the longer the sleep period, the less responsive the blocking, and the shorter the sleep, the more spinning that occurs. </p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li><p>How do various standard functions, like the ones above, block? Native code? while() loops? Something else? </p></li>
  <li><p>How should I implement methods that block?</p></li>
  </ol>