wait abstract method

void wait(
  1. Mutex mutex, {
  2. Duration? timeout,
})

Block and wait until another thread calls notify or notifyAll.

mutex must be a Mutex object exclusively held by the current thread. It will be released and the thread will block until another thread calls notify or notifyAll. Spurious wakes are possible, so callers must check their condition in a loop while holding the mutex.

if a timeout is passed and it expires then a TimeoutException is thrown. The mutex is reacquired before returning or throwing TimeoutException. Reacquiring it can extend the wait beyond timeout. Windows rounds positive timeouts up to milliseconds; POSIX supports microseconds.

Implementation

void wait(Mutex mutex, {Duration? timeout});