Hard👤 8-15 years 1 min read

How do you diagnose high latency or a hang from a production thread dump?

Asked inAmazonMicrosoftDeloitteGoogle
#thread dump#jstack#contention#diagnosis#production
Report issue

⚡ Short Answer

Capture 2–3 dumps a few seconds apart (jstack/jcmd). Look for: a deadlock section, clusters of BLOCKED threads (find the lock owner), many threads stuck in the same stack frame (slow dependency), and threads that don't move between dumps (hung). Correlate with CPU to separate busy from blocked.

Coffee Chat Question

Concept Made Simple

How do you diagnose high latency or a hang from a production thread dump?

🧠Mind Map Answer

Remember It Faster

DeadlockJVM prints it explicitly
BLOCKED clusterlock contention → find owner
Same frame x manyslow downstream call
No movementhung thread

⌨️Hands-on Keyboard

Learn by Doing

bash
jcmd <pid> Thread.print > dump1.txt    # repeat x3, ~5s apart
# or
jstack -l <pid> > dump1.txt
# analyze in fastThread.io / look for BLOCKED + lock owners

🔥What If?

Think Beyond the Expected

Threads are RUNNABLE in a socketRead but latency is high — bug in your app?

Not necessarily your CPU — a thread blocked in native socketRead shows as RUNNABLE. Many threads parked there means a slow/unresponsive downstream (DB, API). The fix is timeouts, connection-pool tuning, and circuit breakers, not app threading.

😂Real World

Thread dumps are the #1 tool for 'the app is slow/hung' incidents: they reveal deadlocks, lock contention hotspots, and threads piled up waiting on a slow database or API — often pointing outside your code.

🎯Interviewer's Expectation

Keywords they're listening for:

multiple dumps over timedeadlock sectionBLOCKED → lock ownersocketRead shows RUNNABLEcorrelate with CPU

⚠️Common Mistakes

  • Taking a single dump (no movement comparison)
  • Assuming RUNNABLE means CPU-bound
  • Not capturing CPU usage alongside

Best Practices

  • Take 2–3 timed dumps + a CPU sample
  • Trace BLOCKED threads to the lock owner
  • Add timeouts/circuit breakers for slow dependencies

🔁Follow-up Questions

  • 1Why take several dumps instead of one?
  • 2How do you find the thread holding a contended lock?
  • 3What does a thread parked in socketRead tell you?

🧩Related Technologies

jstackjcmdasync-profilerfastThread.io

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Deadlocks (Multithreading)
Interview question: "How do you diagnose high latency or a hang from a production thread dump?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.
Open inChatGPTGeminiClaude

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions