Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Threads: Figure out which threads are still running

For debugging purposes, I want to figure out which threads of my program are still running. There's seems to be one or more threads that accidentally were not interrupted. Some sort of nice printable format would be a bonus.

like image 698
well actually Avatar asked Sep 03 '26 03:09

well actually


2 Answers

Use 'jps' command line tool to see active java processes and jstack for showing active threads.

jstack doc

example

like image 147
Petro Semeniuk Avatar answered Sep 05 '26 17:09

Petro Semeniuk


jVisualVM is your friend for this kind of debugging. It's in the /bin directory of your JDK install. Shows all of the threads as a graph view and allows you to drill down into what they're doing. The Thread Dump button will print out all of their current stack traces so you can see if something is stuck somewhere in your user code.

like image 41
Affe Avatar answered Sep 05 '26 16:09

Affe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!