a little madness

A man needs a little madness, or else he never dares cut the rope and be free -Nikos Kazantzakis

Zutubi

Java 1.6: Easier Thread Dumps For All

Thread dumps are an invaluable form of debugging, especially something running at a remote site. When you have no idea what is going on inside your application, a thread dump can be a life saver. However, depending on the operating system and method of launching the application, it can be difficult to get a thread dump by the traditional method (SIGQUIT on Unix and Control+Break in the console on Windows). Either it is difficult to find the right Java process (pre-NPTL Linux), it is difficult to find where stdout is going (when running as a service) or it is impossible to hit Control-Break (no console!).

Well, a couple of tools that first arrived in Unix 1.5 JDKs solve this problem. And now, in Java 1.6, they are available on Windows too. Those tools are jps (a ps for Java processes) and jstack (a tool to dump the threads of a specified Java process). Shipped with the JDK, these tools make getting a thread dump child’s play:

jsankey@pal:~$ jps -l
8328 com.zutubi.pulse.command.PulseCtl
5310 org.tanukisoftware.wrapper.WrapperStartStopApp
4306 org.apache.tools.ant.launch.Launcher
8729 sun.tools.jps.Jps
8350 org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner
jsankey@pal:~$

There you have the PIDs for all Java processes running as the current user, with the name of the main class. To dump the threads, pass the PID to jstack:

jsankey@pal:~$ jstack 8328
Attaching to process ID 8328, please wait…
Debugger attached successfully.
Client compiler detected.
JVM version is 1.5.0_08-b03
Thread 8581: (state = BLOCKED)
– sun.misc.Unsafe.park(boolean, long) @bci=0 (Interpreted frame)

Voila! Of course, if you have a graphical environment available, you can get all the goodness of jconsole too.

Liked this post? Share it!

6 Responses to “Java 1.6: Easier Thread Dumps For All”

  1. December 10th, 2010 at 5:39 pm

    Levitra Reviews says:

    It was a pleasure reading your blog entry. I bookmarked the site for future reference

  2. September 4th, 2011 at 9:14 pm

    Kelqsjya says:

    How many weeks’ holiday a year are there? breast brunette young unzc

  3. September 7th, 2011 at 3:29 pm

    Wpovwpex says:

    A financial advisor russian nymphet
    105

  4. September 8th, 2011 at 3:17 pm

    Mcjdeubz says:

    A staff restaurant nn junior models
    ?

  5. September 18th, 2011 at 7:04 pm

    Vncddwcw says:

    How much were you paid in your last job? pthc booty mgup

  6. July 12th, 2013 at 12:30 am

    panerai 111 says:

    A softly watch Once used up, the 358 is paradoxically a yielding watchfulness : the 47 mm of diameter enables a large apportionment from the 170 grams of ponderousness (that is fit regarding how big the chronometer, because of the titanium). Enhanced refresh is enormous, especially if it’s consumed about the left hands since the diadem preservation doesn’t press about the carpus. Just the the third dimension can shrink but family get familiar to it swiftly. The readability is intellectual in each and every position because of the abstinence from the sun-dial and also to the clutches which are generously covered with Super Luminova. Panerai Luminor Watches The turning bezel is uncompounded to control. The clicks are near and firm. It exudes consistency. Another strap, intellectual for the diving As some fearless owner will maybe go dabbling some octopuses or sun rays with this particular correct toy, Panerai provides another specifical diving nylon material strap on the brooch that can take in the lever cause from the diadem safety. Well notion, it appears of the exhaustless solidness and enables modifying the bigness of the strap to every millimeter, that is beneficial when putting on diving suite. Deduction To bring into proximity a conclusion, this fragment doesn’t inadequate arguments. It’ll please both brand fanatics that need to have an debarring fragment, too for the amateurs of extreme diving watches who definitely are lured by its incapable of wrong manufacture.

Leave a Reply