What Is a Thread Dump?

A quick description of JVM thread dump is provided in this section. A thread dump is a list of all execution thread in a JVM with their stack traces.

What Is Thread Dump? Thread dump is a list of all execution threads in a JVM at a given moment. The status and the stack trace of each thread is also included in the thread dump.

A thread dump is really a snapshot of JVM activity telling you what the JVM is doing at the moment when the thread dump was generated. If you want to know what data objects are there in the JVM, you need to get a different kind of dump, heap dump, which can be generated by the "jmap" tool.

There are 3 important types of information in a thread dump:

1. Thread List - A complete list of execution threads is included in a thread dump, including both threads used by the JVM and threads used by the application. For example, "DestroyJavaVM" listed a thread dump is a JVM thread. "main" is usually the starting thread of the application running by the JVM.

2. Thread Status (or State) - The execution status of each thread is included in a thread dump. The status of a thread tells us what the tread is doing at this moment. A thread can be in one of the following states:

For example, the following lines from a thread dump show "Thread-1" thread is in the state of BLOCKED:

"Thread-1" #9 prio=5 os_prio=0 tid=0x00a3c400 nid=0x36c0 
   waiting for monitor entry [0x14e8f000]
   java.lang.Thread.State: BLOCKED (on object monitor)

3. Stack Trace - The stack trace of each thread is included in a thread dump. The stack trace is a list of statements and methods showing the current execution point of the thread. The first line of the stack trace is the current statement of the lowerest method in the stack. The second line is the statement in the method that calls method in the first line. The third line is the statement in the method that calls the method in the second line. And so on.

For example, the following stack trace from a thread dump shows "Finalizer" thread is waiting on the execution point inside the java.lang.Object.wait() method, which is called by the java.lang.ref.ReferenceQueue.remove() method, which is called by the java.lang.ref.ReferenceQueue.remove() method, which is called by the java.lang.ref.Finalizer$FinalizerThread.run() method:

"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x00982c00 nid=0x18d8 
   in Object.wait() [0x00e7f000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x03c06dd0> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
   - locked <0x03c06dd0> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
   at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

 java - The Java Program Launcher

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

JVM Troubleshooting Tools

 JVM Troubleshooting Tools in JDK

 jinfo - VM Option Value Checker

 jinfo - Changing HotSpot VM Option

 jstack - Stack Tracer to Generate Thread Dump

What Is a Thread Dump?

 Java Thread Deadlock Demo Program

 jstack - Detecting Java Thread Deadlocks

 jmap - JVM Heap Dump Tool

 Printing Histogram of Java Object Heap

 jmap - Generating Heap Dump File

 jhat - Java Heap Analysis Tool

 jhat - Starting Web Server on a Heap Dump File

 Listing Instance Counts of All Classes

 Browsing Object Instance Values

 Object Query Language (OQL)

 Searching for Instances with OQL Statements

 jhsdb - The Java HotSpot Debugger

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 jrunscript - Script Code Shell

 serialver - serialVersionUID Generator

 native2ascii - Native-to-ASCII Encoding Converter

 Outdated Tutorials


 Full Version in PDF/EPUB