On Oracle Solaris or Linux operating systems, the combination of pressing the Control key and the backslash (\) key at the application console (standard input) causes the Java HotSpot VM to print a thread dump to the application's standard output. On Windows, the equivalent key sequence is the Control and Break keys. The general term for these key combinations is the Control+Break handler.
On Oracle Solaris and Linux operating systems, a thread dump is printed if the Java process receives a QUIT signal. Therefore, the kill -QUIT
pid command causes the process with the ID pid to print a thread dump to standard output.
The following sections describe the data traced by the Control+Break handler:
The thread dump consists of the thread stack, including thread state, for all Java threads in the virtual machine. The thread dump does not terminate the application: it continues after the thread information is printed.
Example 2-35 illustrates a thread dump.
The output consists of a number of thread entries separated by an empty line. The Java Threads (threads that are capable of executing Java language code) are printed first, and these are followed by information about VM internal threads. Each thread entry consists of a header line followed by the thread stack trace.
The header line contains the following information about the thread:
Thread name
Indication if the thread is a daemon thread
Thread priority (prio)
Thread ID (tid), which is the address of a thread structure in memory
ID of the native thread (nid)
Thread state, which indicates what the thread was doing at the time of the thread dump. See Table 2-6 for more details.
Address range, which gives an estimate of the valid stack region for the thread
In addition to the thread stacks, the Control+Break handler executes a deadlock detection algorithm. If any deadlocks are detected, the Control+Break handler, as shown in Example 2-36 prints additional information after the thread dump on each deadlocked thread.
If the JVM flag -XX:+PrintConcurrentLocks
is set, then the Control+Break handler will also print the list of concurrent locks owned by each thread.
The Control+Break handler also prints a heap summary. Example 2-37 shows the different generations (areas of the heap), with the size, the amount used, and the address range. The address range is especially useful if you are also examining the process with tools such as pmap
.
If the JVM flag -XX:+PrintClassHistogram
is set, then the Control+Break handler will produce a heap histogram.