How do you get a thread dump in Java?

Capturing a thread dump means asking the JVM to print the current state and full stack trace of every live thread, which is the go-to technique when a Java application appears frozen, unresponsive, or is consuming CPU without obvious cause.

Key Points

Example

If a production server's CPU usage is unexpectedly high, capturing a thread dump with jcmd <pid> Thread.print and correlating it against the JVM's native thread IDs (visible via tools like top -H) lets you identify exactly which Java thread and stack frame is burning CPU.

Interview Tip

A concise interview answer is

To get a thread dump I'd use jcmd <pid> Thread.print, or the older jstack <pid>, both shipped with the JDK — or send a SIGQUIT to the process on Unix systems. It shows every thread's state and stack trace at that instant, which is essential for diagnosing hangs, deadlocks, or unexplained CPU usage.

Last updated: 11 November 2026

Previous question: What happens when an exception occurs inside a synchronized block?

Next question: What are the different ways to achieve synchronization in Java?

More Concurrency and Multithreading interview questions

All Concurrency and Multithreading questions