title: How to differentiate when wait(long timeout) exit for notify or timeout?
body: <p>Having this wait declaration:</p>
  
  <pre><code>public final native void wait(long timeout) throws InterruptedException;
  </code></pre>
  
  <p>It could exit by InterruptedException, or by timeout, or because Notify/NotifyAll method was called in another thread, Exception is easy to catch but...</p>
  
  <p>There is any way to know if the exits cause was timeout or notify?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is a tricky way that could work, (although I don't like it)</p>
  
  <pre><code>          long tBefore=System.currentTimeMillis();
            wait(TIMEOUT);
            if ((System.currentTimeMillis() - tBefore) &gt; TIMEOUT) 
              { 
                 //timeout
              }
  </code></pre>