Java Concurrency Interview

Deadlock, livelock and diagnostics question 142 of 180 senior

How do you read a thread dump? What do you look for first?

A method, in order:

  1. The deadlock section at the bottom, if HotSpot found one.
  2. Cluster the threads by their top frames. Forty threads in the same socketRead0 is the answer; forty in forty places is not a hang.
  3. Follow ownership: - waiting to lock <0x000000076b2c3f10> plus - locked <0x000000076b2c3f10> in another thread names the culprit directly.
  4. Take three dumps twenty seconds apart. Threads that are stuck stay identical; threads that are busy move.
  5. Check the pool threads' names, which is why naming them matters.

Also worth knowing: RUNNABLE in a dump means "not blocked by the JVM", and a thread blocked in native socket I/O still reports RUNNABLE. That misleads people constantly.

diagnostics

Quiz yourself on Deadlock, livelock and diagnostics Suggest a correction