How exactly does Java wait() method work?
<p>Consider that thread 1 is running following code:</p>

<pre><code>while (true) { 
    synchronized (this) {
        wait();
        ...Do Something ...
    }
}
</code></pre>

<p>And lets say we have thread 2 that notifies thread 1, ie:</p>

<pre><code>synchronized (thread1)
    thread1.notify();
}
</code></pre>

<p>My question is lets say thread 1 got woken up, and is doing something (so its running currently).  Then lets say thread2 does notify on thread1 while thread1 is running.
Will thread1 run again when it finishes "do something"?  Or will it just sleep instead?</p>

<p>Is my question clear enough?</p>

<p>Thank you.</p>
