On Linux/Mac, jps -l can be used to see all the current java processes.
Alternative to this command is ps -el | grep -i java but it
can return some extra non-java processes and you may have to manually filter the results.
Note 1:Windows users need to execute Ctrl+Shift+Esc to bring up the Task-Manager
and then manually choose the pid of the Java process.
Once pid is available, jstack <pid> can be used to dump the stack for every thread executing in the JVM.
Alternative to this command is kill -QUIT <pid>
Note 2: It may be required to run these commands
as sudo if there is insufficient access permission to run these.
The above is useful for simple analysis of thread dumps only.
To detect complex deadlocks or frequent analysis of thread dumps, its recommended to use some tools like
Virtual VM, jconsole etc.
Got a thought to share or found a bug in the code? We'd love to hear from you: