Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a thread dump of a Java Web Start application

Is it possible to get a thread dump of a Java Web Start application? And if so, how?

It would be nice if there were a simple solution, which would enable a non-developer (customer) to create a thread dump. Alternatively, is it possible to create a thread dump programmatically?

In the Java Web Start Console I can get a list of threads by pressing 't' but stacktraces are not included.

If answers require certain java versions, please say so.

like image 553
ahu Avatar asked Sep 18 '08 07:09

ahu


People also ask

How do you create a thread dump in Java?

To take a thread dump, navigate to the console used to launch the Java application, and press the CTRL and Break keys together. It's worth noting that, on some keyboards, the Break key isn't available. Therefore, in such cases, a thread dump can be captured using the CTRL, SHIFT, and Pause keys together.

What is JVM thread dump?

A thread dump is a snapshot of the state of all threads that are part of the process. The state of each thread is presented with a so called stack trace, which shows the contents of a thread's stack. Some of the threads belong to the Java application you are running, while others are JVM internal threads.


1 Answers

In the console, press V rather than T:

t:   dump thread list
v:   dump thread stack

This works under JDK6. Don't know about others.

Alternative, under JDK5 (and possibly earlier) you can send a full stack trace of all threads to standard out:

Under Windows: type ctrl-break in the Java console.

Under Unix: kill -3 <java_process_id> (e.g. kill -3 5555). This will NOT kill your app.

One other thing: As others say, you can get the stacks programatically via the Thread class but watch out for Thread.getAllStackTraces() prior to JDK6 as there's a memory leak.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434648

Regards,

scotty

like image 51
scotty Avatar answered Nov 15 '22 04:11

scotty