Does notify/notifyall release the lock being held

No — notify/notifyAll don’t release locks like wait does. The awakened thread can’t run until the code which called notify releases its lock.

This is what the Javadoc says:

The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object’s monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

Leave a Comment