Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

jstack Utility Deep Dive: JVM Thread Dumps, Deadlocks, and Mixed Stacks

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.

jstack utility overview

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.

ToolPosition in JDK 8 docsBest useNotes
jstackLegacy but fully documented troubleshooting utilityThread dumps, deadlock detection, mixed stacks, core-dump analysisSimple and direct for stack-centric debugging
jcmdSuggested in JDK 8 docs as the newer diagnostic utilityBroader diagnostics with command-based interfacePreferred 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 (including java.util.concurrent.locks information).
  • 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

MethodCommand or actionUse caseImportant notes
Standard dumpjstack <pid>General hang/latency investigationEquivalent output to Ctrl+\ or QUIT signal per Oracle docs
Dump with synchronizersjstack -l <pid>Lock contention and concurrency debuggingAdds ownable synchronizer details
Forced dumpjstack -F <pid>When the normal command does not respondSource notes Solaris/Linux support
Mixed stackjstack -m <pid>JNI/native or VM-level investigationIncludes C/C++ frames as well as Java frames
Core-file analysisjstack $JAVA_HOME/bin/java corePost-crash/offline analysisRequires JVM binary and core file
Programmatic captureThread.getAllStackTraces()Application-level diagnosticsUseful when adding in-app debug capability
Debugger viewwhere in jdbInteractive debugging sessionsConvenient 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, long WAITING, and repeating patterns across multiple dumps.
  • Mixed stack clues: use -m when the issue may involve JNI or VM-native code paths.

References

Best practices

  • Start with jstack -l for lock-aware analysis when investigating hangs.
  • If the process is unresponsive, use -F only when needed and note platform constraints.
  • Use -m when Java-only stacks do not explain the issue (native/JNI suspicion).
  • Keep a consistent incident runbook so thread dumps are captured quickly and repeatably.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
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.

Related Posts

4 Open Source Alternatives to Slack for Team Chat: IRC, Let’s Chat, Mattermost, and Rocket.Chat

If you want Slack-like team communication with more control, these four open source options are a practical starting point. This guide compares their strengths, trade-offs, and how to run a short technical pilot.

Read More

Open Source Scanning Software: Evaluate Legacy Tools and Build a Modern SCA Workflow

The original post listed several tool names but no implementation guidance. This revised guide explains what open source scanning means in DevSecOps, how to interpret those legacy names, and how to implement a practical CI scanning workflow.

Read More

Lyca Mobile USSD Shortcuts: Check Balance and Data Balance Quickly

Use these Lyca Mobile USSD shortcuts to check your prepaid balance and remaining data in seconds. This updated reference includes quick steps, a workflow diagram, and troubleshooting guidance.

Read More

Single Sign-On Implementations: Practical Comparison and Evaluation Guide

This guide expands a short 2015 link list of SSO tools into a practical DevOps reference. You will learn how SSO flows work, how to compare implementations, and how to validate integrations with real commands.

Read More

Hydra for Authorized SSH Password Audits: Workflow, Controls, and Root Login Hardening

Hydra can help security and DevOps teams validate password strength in approved environments, but it must be used carefully and legally. This guide covers a safe workflow, key Hydra options, and practical SSH hardening steps to reduce root-login risk.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x