Deadlock, livelock and diagnostics question 142 of 180 senior
How do you read a thread dump? What do you look for first?
- The first stack trace
- Correct: The deadlock section, then shared top frames, then lock owners, then a second dump later
- Only threads in RUNNABLE state
- The heap summary
A method, in order:
- The deadlock section at the bottom, if HotSpot found one.
- Cluster the threads by their top frames. Forty threads in the same
socketRead0is the answer; forty in forty places is not a hang. - Follow ownership:
- waiting to lock <0x000000076b2c3f10>plus- locked <0x000000076b2c3f10>in another thread names the culprit directly. - Take three dumps twenty seconds apart. Threads that are stuck stay identical; threads that are busy move.
- 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.
Quiz yourself on Deadlock, livelock and diagnostics Suggest a correction