Yes you do miss something. From the JavaDoc:
The key property that waiting for a condition provides is that it atomically releases the associated lock and suspends the current thread, just like Object.wait.
Hence, the lock is released when await()
is called.
From the JavaDoc of the await()
method itself:
void await() throws InterruptedException
Causes the current thread to wait until it is signalled or interrupted. The lock associated with this Condition is atomically released and the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:
And the method signal()
awakes a thread which will re-acquire the lock before continuing. From the JavaDoc of the method signal()
:
void signal()
Wakes up one waiting thread. If any threads are waiting on this condition then one is selected for waking up. That thread must then re-acquire the lock before returning from await.