How do you generate and analyze a thread dump from

2019-01-23 19:07发布

How do you generate and analyze a thread dump from a running JBoss instance?

7条回答
Luminary・发光体
2楼-- · 2019-01-23 19:24

There is a JBoss-specific method that is slightly more user-friendly:

http://community.jboss.org/wiki/GenerateAThreadDumpWithTheJMXConsole

This is especially useful when you don't have direct access to the host machine (which "kill" would require).

查看更多
SAY GOODBYE
3楼-- · 2019-01-23 19:25

Two options:

OPTION 1 Generate a thread dump using JMX Console

In order to generate a thread dump:

  1. Open the JMXConsole (for example: http://localhost:8080 )
  2. Navigate to jboss.system:type=ServerInfo mbean (hint: you can probably just CTRL-F and enter type=ServerInfo in the dialog box)
  3. Click on the link for the Server Info mbean.
  4. Navigate to the bottom where it says listThreadDump
  5. Click it and get your thread dump

Notes:

If you are using Internet Explorer you should use File > Save As to save the output instead of copying the data to a text editor. For some reason when you copy the text from Internet Explorer the line breaks are not copied and all of the output ends up on a single line.

OPTION 2 Generate a Thread Dump using Twiddle

Alternatively you can use twiddle to execute the listThreadDump() method and pipe the returned HTML directly to file. Use this command line:

<JBOSS_HOME>/bin/twiddle invoke "jboss.system:type=ServerInfo" listThreadDump > threads.html
查看更多
小情绪 Triste *
4楼-- · 2019-01-23 19:34

Thread.getAllStackTraces() (since Java 1.5)

查看更多
地球回转人心会变
5楼-- · 2019-01-23 19:37

https://community.jboss.org/wiki/ThreadDumpJSP page features standalone self-contained threaddump.war that can be used without JMX.

查看更多
爷、活的狠高调
6楼-- · 2019-01-23 19:38

http://java.sun.com/developer/technicalArticles/Programming/Stacktrace/

...

"On UNIX platforms you can send a signal to a program by using the kill command. This is the quit signal, which is handled by the JVM. For example, on Solaris you can use the command kill -QUIT process_id, where process_id is the process number of your Java program.

Alternatively you can enter the key sequence <ctrl>\ in the window where the Java program was started. Sending this signal instructs a signal handler in the JVM, to recursively print out all the information on the threads and monitors inside the JVM."

...

"Determining the Thread States

You will see many different threads in many different states in a snapshot from a JVM stack trace. The key used is:

R Running or runnable thread

S Suspended thread

CW Thread waiting on a condition variable

MW Thread waiting on a monitor lock

MS Thread suspended waiting on a monitor lock"

查看更多
男人必须洒脱
7楼-- · 2019-01-23 19:41

Sometimes JBoss locks so much that even jmx-concole doesn't respond. In such case use kill -3 on Linux and SendSignal on Windows.

查看更多
登录 后发表回答