title: Behavior of future.get with 0 timeout
body: <p>Can anyone point me to some documentation that makes clear that a 'Future.get` with a timeout of 0 will not wait?</p>
  
  <p>The API docs for <code>java.util.concurrent.Future</code> does not make explicit the behavior of <code>future.get(0, unit)</code>. Standing on its own, the statement "Waits if necessary for at most the given time..." implies this invocation will not wait at all, but given the long-standing behavior of <code>Object.wait(0)</code> (infinite wait), I'm nervous to depend on a "no wait" behavior of <code>future.get(0, unit)</code></p>
  
  <p>Scanning the source of some JDK-provided classes (viz. <code>FutureTask</code>) I see that this particular implementation of <code>Future</code> does not wait when the timeout is 0.</p>
  
  <p>I'd like to be able to say</p>
  
  <pre><code>   long timeout = Math.max(until - now, 0);
     return future.get(timeout, TimeUnit.MILLISECONDS);
  </code></pre>
  
  <p>but I'm nervous about a Future implementing that as an infinite wait, so instead, I've explicitly coded it the way I would expect it to work:</p>
  
  <pre><code>   long timeout = Math.max(until - now, 0);
     if(timeout &gt; 0 || future.isDone()){
        return future.get(timeout, TimeUnit.MILLISECONDS);
     } else {
        throw TimeoutException();
     }
  </code></pre>