OnCallReady

Commands

jstack - print Java thread stack traces for a running Java process

jstack [-l] [-e] pid

Options you will use

-l
Long listing: locked ownable synchronizers (java.util.concurrent locks).
-e
Extended thread information.
-m
Mixed mode (Java and native frames). Removed from jstack in JDK 9: use jhsdb jstack --mixed.

Examples

$ sudo -u appuser jstack -l 1210 > dump1.txt

Same content as jcmd 1210 Thread.print -l.

$ grep -A1 'java.lang.Thread.State' dump1.txt | sort | uniq -c | sort -rn

Cluster threads by state and top frame.

Gotchas

Try jstack in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.