In the previous post, you have seen how to generate Thread Dump on different operating systems. After generating the Thread dump, the next question comes which is “How to read Thread Dump?”. Thread dump provides some generic information in the first part and the later part has the detail of Thread which is used for analysis purposes. Let’s try to understand them with an example:
If you have any Thread Dump then open it either in Java VisualVM or Notepad++ and compare with the below statements.
1. The first row shows the timestamp of the thread dump generation in the below format.
2. The second row shows the JVM information from which the dump had been generated.
Full thread dump OpenJDK 64-Bit Server VM (24.141-b02 mixed mode):
3. Next information is related to the threads. Please refer to the below lines. There are two threads shown below which are having relative information; which helps to analyse the dump. Follow the colour code to see the description of the fields:
When java.util.concurrent.ThreadFactory class generates a thread, then the thread will be named pool-<number>-thread-<number>. As per the above example, the first thread has the name pool-3-thread-1.
When Java.lang.Thread class generates a thread, then the thread will be named Thread-<Number>. In the above example, you can see the second thread having the name “Thread-4”. Actually, the thread name is given in the human-readable format so that analysis can be made easy.
Thread ID (#):
This number represents the unique ID of the thread. It starts from 1 and then increments and is assigned to a newly created thread. This thread ID is very useful to get information like CPU usage and memory usage of the thread. In the above example, #37 and #34 are the thread IDs of respective threads.
This tag shows whether the thread is a daemon thread or a non-daemon thread. If the thread is a daemon then this tag will be present. If the thread is a non-daemon thread then no tag will be present. In the above example, the first thread is a daemon thread whereas the second thread is a non-daemon thread. Therefore you can see the daemon attribute is absent for the first thread.
Note: To get more information about the type of threads please refer to the post.
Thread Priority (prio):
This tag represents the priority of the threads. The first thread has priority 5 whereas the second thread has priority 1 in the above example.
OS Thread Priority (os_prio):
The priority of the thread in OS term. You can see 0 and -2 are os_prio of respective threads.
The memory address of the Java native thread object.
OS Thread ID (nid):
The unique ID of the OS thread to which the Java Thread is mapped.
The status of the thread when the thread dump was generated. We have already discussed all the states of a thread in the Life Cycle of Thread post.
Stack Point and rest of the tags:
The rest of the information is related to the resources used by the thread. Some of the resources are locked by the thread and for some resources, the thread waits which can be easily understood by reading the statements. Specially this information is used for analysis and diagnostic purposes. Refer to the next post to understand the thread dump analysis part in detail.
You may be interested: