The wait() method releases the lock, and then blocks until it is
awakened by a notify() or notifyAll() call for the same condition
variable in another thread. Once awakened, it re-acquires the lock and
returns. It is also possible to specify a timeout.
The notify() method wakes up one of the threads waiting for the
condition variable, if any are waiting. The notifyAll() method wakes
up all threads waiting for the condition variable.
Note: the notify() and notifyAll() methods don’t release the lock;
this means that the thread or threads awakened will not return from
their wait() call immediately, but only when the thread that called
notify() or notifyAll() finally relinquishes ownership of the lock.
官方documentation对此给出了答案:
相关问题 更多 >
编程相关推荐