This discussion is archived
3 Replies Latest reply: Nov 18, 2010 7:16 PM by doremifasollatido RSS

Find current running threads in an JVM (JDK 1.5)

andy dufresne Newbie
Currently Being Moderated
Is there any application which can capture the information about currently running threads in an already spawned jvm, given its process id as input?
This is similar to what jstack does but since its present only in JDK 1.6 (at least for Windows) I am not able to take the advantage of it.

Any help would be appreciated.

Thank you.
  • 1. Re: Find current running threads in an JVM (JDK 1.5)
    796440 Guru
    Currently Being Moderated
    You can look and see if jconsole is present. I'm not sure when that was introduced.

    If you're running in windows, and the process was started from a command shell to which you have access ctl-break or alt-break or something will give a thread dump. I don't know if there's a way to send that signal from outside the launching cmd shell in windows. In Linux/Unix, you can send the process a signal, from any command shell, to get a thread dump. I forget which signal, but you can google for it.
  • 2. Re: Find current running threads in an JVM (JDK 1.5)
    802316 Pro
    Currently Being Moderated
    I won't remind you that Java 5.0 has been EOL for more than a year and Java 6 is almost four year old now... ;)

    In Java 5.0 you can call Thread.getAllStackTraces() This will give you all the current threads and their stack trace. It should be fairly easy to write a tool which triggers this and outputs it appropriately.
    Without this you need to use the signal for linux and ctrl_break for windows to get a thread dump/stack trace.
  • 3. Re: Find current running threads in an JVM (JDK 1.5)
    doremifasollatido Journeyer
    Currently Being Moderated
    jverd wrote:
    You can look and see if jconsole is present. I'm not sure when that was introduced.

    In Linux/Unix, you can send the process a signal, from any command shell, to get a thread dump. I forget which signal, but you can google for it.
    kill -3 PID
    (where PID is the process ID)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points