Originally published on 2016-01-25; fully revised and updated.
The jstack utility is a JVM troubleshooting tool for capturing thread dumps and detecting deadlocks. This article is for DevOps and platform engineers who need fast, reliable thread-level diagnostics in production or pre-production environments, with practical commands and a clear triage workflow.

Where jstack fits in JVM diagnostics
Oracle JDK 8 troubleshooting documentation introduced Java Mission Control, Java Flight Recorder, and jcmd, and suggests using jcmd instead of jstack for enhanced diagnostics and lower overhead in many cases. Even so, jstack remains a direct and widely used way to obtain thread dumps, detect deadlocks, inspect core files, and print mixed Java/native stacks.
| Tool | Position in JDK 8 docs | Best use | Notes |
|---|---|---|---|
jstack | Legacy but fully documented troubleshooting utility | Thread dumps, deadlock detection, mixed stacks, core-dump analysis | Simple and direct for stack-centric debugging |
jcmd | Suggested in JDK 8 docs as the newer diagnostic utility | Broader diagnostics with command-based interface | Preferred by JDK 8-era guidance for reduced overhead |
What jstack can collect
- Stack traces for all threads attached to a JVM, including Java threads and VM internal threads.
- Deadlock detection in Java-level locking scenarios.
- Ownable synchronizer details with
-l(includingjava.util.concurrent.locksinformation). - Mixed Java and native C/C++ frames with
-m. - Stack traces from a core dump.
- Remote querying via
jsadebugd(with slower output, as noted in the source material).
Thread-dump methods and when to use them
| Method | Command or action | Use case | Important notes |
|---|---|---|---|
| Standard dump | jstack <pid> | General hang/latency investigation | Equivalent output to Ctrl+\ or QUIT signal per Oracle docs |
| Dump with synchronizers | jstack -l <pid> | Lock contention and concurrency debugging | Adds ownable synchronizer details |
| Forced dump | jstack -F <pid> | When the normal command does not respond | Source notes Solaris/Linux support |
| Mixed stack | jstack -m <pid> | JNI/native or VM-level investigation | Includes C/C++ frames as well as Java frames |
| Core-file analysis | jstack $JAVA_HOME/bin/java core | Post-crash/offline analysis | Requires JVM binary and core file |
| Programmatic capture | Thread.getAllStackTraces() | Application-level diagnostics | Useful when adding in-app debug capability |
| Debugger view | where in jdb | Interactive debugging sessions | Convenient in live debug workflows |
Practical jstack command examples
Standard thread dump
jstack <pid>Code language: HTML, XML (xml)
Include ownable synchronizers
jstack -l <pid>Code language: HTML, XML (xml)
Force a stack dump from a hung process
jstack -F <pid>Code language: HTML, XML (xml)
Print mixed Java/native frames
jstack -m <pid>
jstack -m <pid> | c++filtCode language: HTML, XML (xml)
In mixed-stack output, frames prefixed with an asterisk (*) are Java frames; non-prefixed frames are native C/C++ frames.
Read stacks from a core dump
jstack $JAVA_HOME/bin/java coreCode language: PHP (php)
As documented by Oracle, you can also get equivalent thread-dump output via Ctrl+\ on the console or by sending QUIT to the JVM process.
Troubleshooting workflow for hangs and deadlocks
flowchart TD
A[Service appears hung] --> B[Find JVM pid]
B --> C[Run jstack pid]
C --> D{Command responds}
D -- yes --> E[Run jstack -l pid]
D -- no --> F[Run jstack -F pid]
E --> G[Check deadlock section]
F --> G
G --> H[If needed run jstack -m pid]
H --> I[Identify lock or native stall]
I --> J[Apply fix and validate]
How to read key output signals quickly
- Deadlock indicator: look for lines like
Found one Java-level deadlock. - Lock ownership clues: lines stating one thread is waiting to lock an object held by another thread.
- Thread state focus: prioritize
BLOCKED, longWAITING, and repeating patterns across multiple dumps. - Mixed stack clues: use
-mwhen the issue may involve JNI or VM-native code paths.
References
- Troubleshoot with jstack Utility (Oracle JDK 8)
- Force a Stack Dump
- Stack Trace from a Core Dump
- Mixed Stack
- Control+Break Handler
- jstack command man page (Oracle JDK 8)
Best practices
- Start with
jstack -lfor lock-aware analysis when investigating hangs. - If the process is unresponsive, use
-Fonly when needed and note platform constraints. - Use
-mwhen Java-only stacks do not explain the issue (native/JNI suspicion). - Keep a consistent incident runbook so thread dumps are captured quickly and repeatably.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals