~/ 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/89c90851-296f-4d55-beaf-06ed29eff7a5/flashcard utf-8 LF