Question

I want to get the thread dump of my web app that running on a jboss server.

I found two solutions for my problem :

  • Using the unix command : kill -3
  • Using the jstack tool that exists in the JDK.

Can anyone explain to me the difference between theses two methods?

Thanks in advance !

Était-ce utile?

La solution

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.

Autres conseils

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:

  • Jstack performs deadlock detection by default.
  • 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)

In Windows you have something called "taskkill /PID {yourpid} /F" for killin process. The process id can be obtained from netstat command or use viusal vm to know process id

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top