liveBook · Manning

Waiting time

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

The amount of time a thread spends waiting rather than executing.

Waiting time measures how long a thread is blocked instead of executing. It can reveal performance costs that a count of lock events alone misses. section 9.3

Compare lock counts with waiting time

In a producer-consumer example, adding wait/notify reduces the number of locks but increases waiting time and total execution time. Sampling and profiling expose the tradeoff; JProfiler can show both lock counts and waiting time grouped by thread. 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.

Distinguishes a thread waiting at a synchronized block from one explicitly put into the waiting state by the monitor. section 9.3

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

How deep it goes
Compares sampled execution and profiler results, but does not develop a general method for optimizing waiting time.
Examples
Compares producer-consumer threads using wait/notify with earlier lock behavior.
What you can do after
Diagnose performance tradeoffs by comparing lock counts, waiting time, and total execution time in profiler results.
How it connects
Connects waiting time with threads, synchronized blocks, monitors, wait/notify, and profiling.

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.