30

I want to know what a java thread dump is. Can someone please help me understand what a thread dump is and how it relates to a running java program?

Ogre Psalm33
  • 21,366
  • 16
  • 74
  • 92
9ine
  • 879
  • 2
  • 8
  • 18
  • 3
    It literally dumps the name and stack (where the program is running) of every thread. It can be used to help work out what your program is doing. VisualVM is one of the best ways to visualise all the threads in your process. – Peter Lawrey Sep 05 '12 at 08:12
  • 6
    *"please share me some knowledge."* These questions can often be answered by putting the keywords in a search engine. In this case, search on "java+thread+dump". – Andrew Thompson Sep 05 '12 at 08:22
  • 14
    Just googled for "thread dump meaning" and the first result was this stackoverflow question. That's what makes stackoverflow a great platform for all kinds of devs, basic questions shouldn't be discouraged. – Marcelo Oliveira Oct 10 '13 at 19:07

4 Answers4

33

A Java thread dump is a way of finding out what every thread in the JVM is doing at a particular point in time. This is especially useful if your Java application sometimes seems to hang when running under load, as an analysis of the dump will show where the threads are stuck.

You can generate a thread dump under Unix/Linux by running kill -QUIT <pid>, and under Windows by hitting Ctl + Break.

To Know how to take thread dump from JVM see here

To know how to create thread dump see here

heretolearn
  • 6,387
  • 4
  • 30
  • 53
16

From http://www.javasanity.org/understandingthreaddumps:

The thread dump is a snapshot of exactly what's executing at a moment in time

There are plenty of resources out there that can help you understand/analyse a thread dump (for instance http://www.javacodegeeks.com/2012/03/jvm-how-to-analyze-thread-dump.html).

You might also find the following question useful: Thread Dump Analysis Tool / Method

Community
  • 1
  • 1
Xavi López
  • 27,550
  • 11
  • 97
  • 161
2

"A thread dump is a list of all the Java threads that are currently active in a Java Virtual Machine (JVM)." (link)

Usually, a thread in this list is represented by its current stacktrace and the state of the thread (running, suspended, locked, etc.)

Alexander Pavlov
  • 31,598
  • 5
  • 67
  • 93
1

A thread dump is an output of the state of the call stack at the point when your programme failed. This should let you work out want went wrong in the programme, because it shows exactly what the programme was doing (and why).

Do you have a thread dump you need looking at?

hcarver
  • 7,126
  • 4
  • 41
  • 67