wait


Description:

public void wait (Mutex mutex)

Atomically releases mutex and waits until this is signalled.

When this function returns, mutex is locked again and owned by the calling thread.

When using condition variables, it is possible that a spurious wakeup may occur (ie: wait returns even though @signal was not called). It's also possible that a stolen wakeup may occur. This is when @signal is called, but another thread acquires mutex before this thread and modifies the state of the program in such a way that when wait is able to return, the expected condition is no longer met.

For this reason, wait must always be used in a loop. See the documentation for Cond for a complete example.

Parameters:

this

a Cond

mutex

a Mutex that is currently locked