I want to get the thread dump of my web app that running on a jboss server.
I found two solutions for my problem :
Can anyone explain to me the difference between theses two methods?
Thanks in advance !
Description. The jstack command prints Java stack traces of Java threads for a specified Java process. For each Java frame, the full class name, method name, byte code index (BCI), and line number, when available, are printed. C++ mangled names aren't demangled.
JMap and JStack are probably the most valuable utilities in the toolbox of any Java developer. With the functionality of both these tools combined, you can debug issues and run diagnostics for the java program you're coding.
jstack is a command-line JDK utility we can use to capture a thread dump. It takes the pid of a process and displays the thread dump in the console. Alternatively, we can redirect its output to a file. Let's take a look at the basic command syntax for capturing a thread dump using jstack: jstack [-F] [-l] [-m] <pid>
The jstack
command can get a thread dump of a program running on a remote machine, and it also works on Windows.
kill -3
only works on local programs, and on Windows there is no kill
.
From the oracle page of jstack:
The output from the jstack pid option is the same as that obtained by pressing Ctrl+\ at the application console (standard input) or by sending the process a QUIT signal.
Also remember that Ctrl+\ is equivalent to a SIGQUIT
.
From what is kill -3 (unix.se):
kill -l shows us all signals. Following this hint 3 means SIGQUIT
So basically both of them do exactly the same thing, i.e asking for a coredump. Here are some pointers related to jstack:
Regarding official support, from the jstack man page:
Prints Java thread stack traces for a Java process, core file, or remote debug server. This command is experimental and unsupported.
This utility is unsupported and might not be available in future release of the JDK. In Windows Systems where the dbgeng.dll file is not present, Debugging Tools For Windows must be installed so these tools work.
Regarding the output difference, its basically the same thing. There is a one to one mapping between the outputs. See my output for the same application to demonstrate the mapping between the statuses of kill -3
and jstack
. The mapping between the statuses are:
kill -3 | Jstack
------------------------------
RUNNABLE | IN_NATIVE
TIMED_WAITING | BLOCKED
WAITING | BLOCKED (PARK)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With