Figure 9-2. View of live threads in JConsole
Blocked Thread Visibility
Real-time thread monitoring is useful for a very high-level picture of what threads are run-
ning in the application, but it doesn't really provide any data on what those threads are doing.
Determining where the threads are spending CPU cycles requires the use of a profiler, as dis-
cussed in Chapter 3 . Profilers provide great visibility into what threads are executing, and
they are generally sophisticated enough to guide you to areas in the code where better al-
gorithms and code choices can speed up overall execution.
It is more difficult to diagnose threads that are blocked, although that information is often
more important in the overall execution of an application—particularly if that code is run-
ning on a multi-CPU system and is not utilizing all the available CPU. There are three ap-
proaches to performing this diagnosis. One approach is again to use a profiler, since most
profiling tools will provide a timeline of thread execution that allows you to see the points in