the others; thus restarted threads do not begin executing until the operation is complete.) enter the monitor: enter the method if the monitor is locked add this thread to e block this thread else lock the monitor leave the monitor: schedule return from the method wait : add this thread to .q schedule block this thread notify : if there is a thread waiting on .q select and remove one thread t from .q (t is called "the notified thread") move t to e notify all : move all threads waiting on .q to e schedule : if there is a thread on e select and remove one thread from e and restart it else unlock the monitor As a variation on this scheme, the notified thread may be moved to a queue called w, which has priority over e. See Howard and Buhr et al. for further discussion. It is possible to associate an assertion with each condition variable such that is sure to be true upon return from wait . However, one must ensure that is preserved from the time the notifying thread gives up occupancy until the notified thread is selected to re-enter the monitor. Between these times there could be activity by other occupants. Thus it is common for to simply be true. For this reason, it is usually necessary to enclose each wait operation in a loop like this while not ( ) do wait c where is some condition stronger than . The operations notify and notify all are treated as "hints" that may be true for some waiting thread. Every iteration of such a loop past the first represents a lost notification; thus with nonblocking monitors, one must be careful to ensure that too many notifications cannot be lost. As an example of "hinting," consider a bank account in which a withdrawing thread will wait until the account has sufficient funds before proceeding monitor class Account { private int balance := 0 invariant balance >= 0 private NonblockingCondition balanceMayBeBigEnough public method withdraw(int amount) precondition amount >= 0 { while balance < amount do wait balanceMayBeBigEnough assert balance >= amount balance := balance - amount } public method deposit(int amount) precondition amount >= 0 { balance := balance + amount notify all balanceMayBeBigEnough } } In this example, the condition being waited for is a function of the amount to be withdrawn, so it