~/ learn/ comp-308/ cards/ Coordination: wait/notify, suspend/resume, interrupts
1 of 6

Type a guarded block that waits in a while loop

Type a guarded block that waits in a while loop

Answer

synchronized (lock) { while (!ready) { lock.wait(); } }

wait() releases the monitor and parks until notified; the while loop re-checks the condition to guard against spurious wakeups and stale state.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/4921f4ce-0cf6-45be-82ed-9433d4ccdf22/flashcard utf-8 LF