Java Reference
In-Depth Information
run normally. Your program doesn't have to be suspended to create a thread
dump; you don't even have to be running under the debugger.
Customizing Threads view
Expanding a thread shows its stack frames, if it has any, listed by the frame's
method call. Right-click a stack frame reference and select
Show Frame
from the
menu to view the current frame's detail in the
Frame
tab and see the source ref-
erence in the main editor window. In addition, you can use the
Customize View
dialog to control how these stack frames are displayed, via the context menu in
the
Threads
tab of the
Debug
tool window. The following display options are
available from this dialog:
Show line number
includes the line number of the method call.
■
Show class name
includes the name of the class containing the method.
■
Show source filename
includes the name of source file that contains the
method.
■
Java threads can be organized into
thread groups
, collections of related threads
that can be managed as a single unit. By default,
IDEA
doesn't show these threads
groups, but you can easily change this by opening the
Customize View
dialog
and selecting the
Show thread groups
option. Threads will now appear in a hier-
archy of thread groups, allowing you to drill down into each group to access its
member threads.
6.4 Viewing runtime data in the debugger
Being able to peek inside the
VM
and examine the values stored in your objects is
often the key to finding out what's going wrong inside your code. As soon as you
locate when and where things go south, you're well on your way to devising a solu-
tion. Toward that end, the debugger allows you to explore current runtime values
and expressions and even change values or classes on the fly. You can only view
these values while your program is suspended, however.
6.4.1
Understanding the Java call stack
When you examine a running application, you do so by glancing into the call
stack. To understand why this is, and to use the debugger effectively, you must
understand how the Java stack works. Like most languages, Java applications
use a data structure known as a
call stack
to keep track of things while executing.
The call stack holds a list of
stack frames
. A stack frame is all the data associated