liveBook · Manning

Waiting thread

As explained in Troubleshooting Java: Read, debug, and optimize JVM applications

A thread suspended while awaiting notification from the monitor on which it is waiting.

A waiting thread has been suspended by its monitor and resumes only after that same monitor notifies it. Unlike a thread locked at a synchronized-block entrance, it was explicitly made to wait inside the monitor’s synchronized region. section 9.3

A shared producer-consumer list

A consumer calls wait() when the list is empty; a producer waits when the list reaches 100 values. After removing or adding a value, each calls notifyAll(). section 9.3

Figure 9.14 Locked threads versus waiting threads. A locked thread is blocked at the entrance of a synchronized block. The monitor won’t allow a thread to enter a synchronized block while another thread actively runs inside the block. A waiting thread is a thread that the monitor has explicitly set to the blocked state. The monitor can make any thread inside the synchronized block it manages wait. The waiting thread can continue its execution only after the monitor explicitly tells it that it can proceed with its execution.

Compare a thread blocked at a synchronized-block entrance with one explicitly put into the waiting state by its monitor. section 9.3

How Troubleshooting Java: Read, debug, and optimize JVM applications covers it

How deep it goes
Contrasts waiting with entry locking, demonstrates wait/notifyAll, and notes slower runs and longer blocking without exploring misuse risks.
Examples
Uses a bounded shared list: consumers wait when it is empty, producers when it is full, and both notify after changing it.
What it assumes
Assumes a shared-list producer-consumer setup and synchronized access, while distinguishing waiting from lock-entry blocking.
What you can do after
Apply it via Java monitor wait/notifyAll to suspend consumers on empty lists and producers on full lists.
How it connects
Connects monitor waiting to synchronized blocks, monitors, and producer-consumer coordination.

Also explained in

Compare how 2 books explain waiting thread →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java: Read, debug, and optimize JVM applications. The section links point to the parts of the book it draws on.