How to Get a Unix Thread Dump

It is often useful to get a dump of the threads of a Jrun Server (which is being run under a Java Virtual Machine). One common reason, for example, may be when the server is not responding to requests from Web Browsers. If in such a situation it is decided to restart the Jrun server, it is very useful to first take a 'thread dump' to help determine the cause of the 'hang'. Even in less 'drastic' situations it may be helpful to see the number and state of the various threads in the JVM.

To take a thread dump, you need to know the process id (pid) of the Jrun Server. You can get this by entering the following:

ps -ef | grep some-identifying-string

Where the 'idetifying-string' is either the word 'jrun', your logon id, or the name of the Jrun Server. It should show a line (among others) that looks something like this:

nobody  8952  1  0 12:24:07 ? 0:14 /export/opt/jrun/4.0.1a/bin/jrun -config /export/enterprise-docs/gem/jserv/SER

In the above line is for app shortname 'gem', and its process id is 8952. Then all you to do is the following:

kill -3  8952

The output will go to the 'out' log file in the /logs directory for that Jrun Server.

There is a trace-back for each thread in the JVM that looks something like this:

"Thread-4" prio=5 tid=0x24da48 nid=0x22 in Object.wait() [db801000..db8019f4]
at java.lang.Object.wait(Native Method)
- waiting on <dec61180> (a java.util.LinkedList)
at java.lang.Object.wait(
- locked <dec61180> (a java.util.LinkedList)

It is usually very helpful to get line numbers in the traceback, as we see in the example above. It may happen that the line numbers do not appear. This sometimes is due to the fact that the JVM was started with the request to use the 'just in time' compiler. If that is the case, you can change the following java parm not to use the 'just in time' compiler:

java args= -Dnojit

Here is a web pages that describes this technique: