Tomasz Nurkiewicz wrote a nice blog entry (“Which Java thread consumes my CPU?“) in which he shows a simple method that relies on standard GNU/Linux command-line tools to gather information about the Java threads that keep your CPU very busy.
I wondered whether it would be possible to make it slightly simpler by removing some dependencies and regular expressions and came up with the following Bash shell script:
I think it can be made even simpler and with less dependencies.
Feel free to accept this as a challenge and enlighten me
PS: According to Oracle’s jstack web page
This utility is unsupported and may or may not be available in future versions of the J2SE SDK. jstack is not currently available on Windows platforms or on the Linux Itanium platform.
Apparently jstack is still going strong as of 2012, at least on an up-to-date Ubuntu GNU/Linux system, but who knows what awaits us in the future, especially if it is controlled by Oracle

Ali Utku Selen
August 28, 2012 at 16:27
pssst… use VisualVM.
Emre Sevinc
August 28, 2012 at 16:36
And stay away from the joys of the command line which was the main point of this exercise ?
(Not that I don’t like VisualVM and other members of the family, though)