Java Thread Dump Analyzer
Thread:
A thread is a PC program that is stacked into the PC's memory and is under execution. It tends to be executed by a processor or a bunch of processors. A thread is depicted in memory with significant data, for example, factor stores, record handles, the program counter, registers, and, signals, etc.
A cycle can comprise numerous lightweight cycles called a thread. This assists with accomplishing parallelism wherein an interaction is separated into different strings. This outcome in better execution. Every one of the strings inside a cycle shares a similar memory space and is reliant upon one another.
Thread Dump
At the point when the thread is executing, we can identify the present status of execution of the thread in the process utilizing thread dumps. A thread Dump contains a depiction of the multitude of thread dynamics at a specific point during the execution of a program. It contains all significant data about the string and its present status.
A cutting-edge application today includes different quantities of strings. Each string requires specific assets and plays out specific exercises connected with the interaction. This can support the exhibition of application threads that can use accessible central processor centres.
In any case, there are compromises, for example, once in a while different threads may not facilitate well with one another and a halt circumstance might emerge. In this way, in the event that something turns out badly, we can utilize string dumps to review the condition of our strings.
Thread Dump in Java
A JVM thread Dump is a posting of the condition of all processes that are important for the process at that specific mark of time. It contains data about the thread's stack, introduced as a stack follow. As it is written in plaintext, the items can be put something aside for survey later. Examination of thread dumps can help in
- Streamlining JVM execution
- Streamlining application execution
- Diagnosing issues, for example, a halt, string conflict, and so on.
Creation of Java Thread Dump
There are numerous ways of producing thread dumps. The following are some JVM-based devices that can be executed from the order line/terminal (CLI apparatuses) or the/receptacle (GUI instruments) index of the establishment envelope of Java.
1. jStack:
The easiest method for producing a thread dump is by utilizing jStack. jStack ships with JVM and can be utilized from the order line. Here, we really want the PID of the cycle for which we need to create the string dump. To get PID we can utilize jps order as displayed beneath.
On Windows:
C:\Program Files\Java\jdk1.8.0_171\bin>jps -l
47172 portal
6120 sun.tools.jps.Jps
C:\Program Files\Java\jdk1.8.0_171\bin>
On Linux:
[[email protected] ~]# jps -l
1088 /opt/keycloak/jboss-modules.jar
26680 /var/lib/jenkins/workspace/kyc/kyc/target/kyc-1.0.jar
7193 jdk.jcmd/sun.tools.jps.Jps
2058 /usr/share/jenkins/jenkins.war
11933 /var/lib/jenkins/workspace/admin-portal/target/portal-1.0.jar
[[email protected] ~]#
As we can see here, we get a rundown of all running java processes. It contains the neighbourhood VM id for the running java process and the name of the application in sections one and two separately. Presently, to produce the thread dump, we utilize the jStack program with a - l banner which makes a long recorded result of the landfill. We can likewise pipe the result to some text record.
jstack -l 26680:
2022-10-20 06:04:53
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.221-b11 mixed mode):
"Attach Listener" #16287 daemon prio=9 os_prio=0 tid=0x00007f0814001800 nid=0x4ff2 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"logback-8" #2316 daemon prio=5 os_prio=0 tid=0x00007f07e0033000 nid=0x4792 waiting on condition [0x00007f07baff8000]
java.lang.Thread.State: WAITING (parking)
atsun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006ca9a1fc0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1081)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
atjava.lang.Thread.run(Thread.java:748)
Locked ownable synchronizers:
- None
"logback-7" #2315 daemon prio=5 os_prio=0 tid=0x00007f07e0251800 nid=0x4791 waiting on condition [0x00007f07bb0f9000]
java.lang.Thread.State: WAITING (parking)
atsun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006ca9a1fc0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1081)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
atjava.lang.Thread.run(Thread.java:748)
Locked ownable synchronizers:
- None
2. Jvisualvm:
Jvisualvm is a GUI instrument that assists us with investigating, screen and profiling Java applications. It additionally accompanies JVM and can be sent off from the/receptacle catalogue of our java establishment. It is exceptionally instinctive and simple to utilize. Among different choices, it likewise permits us to catch thread dumps for a specific cycle.
To see the string dump for a specific cycle, we can right-tap on the program and select thread Dump from the setting menu.
3. Jcmd:
JCMD is an order line utility that boats with the JDK and is utilized to send symptomatic order solicitations to the JVM.
It anyway works just on the neighbourhood machine where the Java application is running. It tends to be utilized to control Java Flight Accounts and analyze and investigate JVM and Java applications. We can utilize the Thread. print order of jcmd to get a rundown of string dumps for a specific cycle determined by the PID.
4. JMC:
JMC represents Java Mission Control. It is an open-source GUI device that boats with JDK and is utilized to gather and examine java application information.
It very well may be sent off from the/receptacle organizer of our Java establishment. Java chairmen and engineers utilize the apparatus to assemble point by point low-level data about the JVM's and application's ways of behaving. It empowers nitty gritty and productive examination of information gathered by Java Flight Recorder.
On sending off jmc, we can see rundown of java process which is running on the neighborhood machine. A far off association is likewise conceivable. On a specific cycle, we can right snap and pick Start Flight Recording and afterward check the string dumps in the Strings tab.
5. jconsole:
jconsole is a Java The executives Expansion device utilized for grumbling administration and checking.
It likewise has a bunch of predefined procedure on the JMX specialist which the client can perform. It empowers the client in identifying and examining stack hint of a live program. It tends to be sent off from the/container organizer of our Java establishment.
Utilizing the jconsole GUI device we can review each string's stack follow when we interface it to a running java process. Then, in the String tab, we can see the name of every single running string. To identify a halt, we can tap on the Recognize Gridlock in the base right of the window. On the off chance that a halt is identified it will show up in another tab in any case a No Gridlock Distinguished will be shown.
6. ThreadMxBean:
ThreadMXBean is the point of interaction for the administration of the string arrangement of the Java virtual machine having a place with java.lang.Management bundle. It is for the most part used to identify the strings which have entered a stop circumstance and get insights concerning them.
We can utilize the ThreadMxBean point of interaction to automatically catch the string dump. getThreadMXBean() technique for ManagementFactory is utilized to get an example of the ThreadMXBean interface. It returns the quantity of both daemon and non-daemon live strings. ManagementFactory is an industrial facility class for getting the overseen beans for the Java stage.
private static String getThreadDump (booleanlockMonitors, booleanlockSynchronizers) {
StringBufferthreadDump = new StringBuffer (System.lineSeparator ());
ThreadMXBeanthreadMXBean = ManagementFactory.getThreadMXBean ();
for (ThreadInfothreadInfo : threadMXBean.dumpAllThreads (lockMonitors, lockSynchronizers)) {
threadDump.append (threadInfo.toString ());
}
returnthreadDump.toString ();
}
Manual Analysis of Thread Dumps
Examination of thread dumps can be extremely helpful in pinpointing issues in multithreaded processes. Issues like gridlocks, lock disputes, and the abundance of computer chip usage by individual string dumps can be settled by imagining the conditions of individual string dumps.
The greatest throughput from the application can be accomplished by redressing the situation with each string subsequent to breaking down the thread dump.
For example, suppose, an interaction is spending a ton of computer processor, we can see whether any string is utilizing the computer chip the most. In the event that there's any such string, we convert its LWP number to a hexadecimal number. Then, at that point, from the string dump, we can track down the string with nid equivalent to the recently acquired hexadecimal number. Utilizing the stack hint of the string we can pinpoint the issue. We should figure out the cycle id of the string utilizing the beneath order.
ps -mopid,lwp,stime,time,cpu -C java
PID LWP STIME TIME %CPU
26680 - Dec07 00:02:02 99.5
- 10039 Dec07 00:00:00 0.1
- 10040 Dec07 00:00:00 95.5
We should view beneath lump of thread dump. To get string dump for process 26680, use jstack - l 26680
2020-06-27 09:01:29
<strong>Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.221-b11 mixed mode):</strong>
"Attach Listener" #16287 daemon prio=9 os_prio=0 tid=0x00007f0814001800 nid=0x4ff2 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
.
.
.
.
.
.
.
"<strong>Reference Handler</strong>" #2 daemon prio=10 os_prio=0 tid=0x00007f085814a000 nid=0x6840 in Object.wait() [0x00007f083b2f1000]
java.lang.Thread.State: WAITING (on object monitor)
atjava.lang.Object.wait(Native Method)
atjava.lang.Object.wait(Object.java:502)
atjava.lang.ref.Reference.tryHandlePending(Reference.java:191)
- locked <0x00000006c790fbd0> (a java.lang.ref.Reference$Lock)
atjava.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
Locked ownable synchronizers:
- None
"VM Thread" os_prio=0 tid=0x00007f0858140800 nid=0x683f runnable
"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f0858021000 nid=0x683b runnable
"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f0858022800 nid=0x683c runnable
"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007f0858024800 nid=0x683d runnable
"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007f0858026000 nid=0x683e runnable
"VM Periodic Task Thread" os_prio=0 tid=0x00007f08581a0000 nid=0x6847 waiting on condition
JNI global references: 1553
Presently, we should find out what things we can investigate utilizing java dumps. On the off chance that we notice the string dump, we can see a ton of content, which can overpower it. Not with standing, in the event that we approach it slowly and carefully, it tends to be genuinely easy to comprehend. We should grasp the principal line
Full java dump Java HotSpot(TM) 64-Digit Server VM (25.221-b11 blended mode):
The above shows the time the landfill was created, and data about the JVM which was utilized. Then, eventually, we can see the rundown of strings, the first among them is our ReferenceHandler thread.
Analyzing Blocked Threads:
Assuming we break down the beneath thread dump logs, we can find that it has identified strings with BLOCKED status which makes the presentation of an application exceptionally sluggish. Thus, on the off chance that we can find the BLOCKED threads, we can attempt to remove the strings connected with the locks that the threads are attempting to get. Examination of the stack following the structure of the string presently holding the lock can help in tackling the issue.
Analyzing Deadlocked Thread:
One more usually utilized use of thread dumps is the location of deadlocks. The location and arrangement of stops can be much more straightforward assuming that we investigate the thread dumps.
Deadlock:A deadlock is what is happening including something like two threads where the asset expected by one thread to proceed with execution is locked by another thread and simultaneously, the asset expected continuously thread is locked by the main thread.
Thus, none of the threads can proceed with the execution, and this outcome is a stop circumstance and finishes the application stalling out. In the event that dreadlocks are available, the last part of the string dump will print out the data seeing the deadlock.
Here we can see the deadlock data in a genuinely comprehensible organization.
Other than this, in the event that we summarize all the above lump of thread dumps together, it expresses the underneath data.
- Reference overseer is the comprehensible name of the thread.
- #2 is the string's exceptional id.
- daemon signifies in the event that the thread is a daemon thread.
- The numeric need of the string is given by prio=10.
- The ongoing status of the string is meant by looking out for condition.
- Then, at that point, we see the stack follow, which incorporates the locking data.
Thread Dumps Analyzers:
Other than manual examination, there are various apparatuses accessible for investigating thread dumps, both on the web and disconnected. The following are a portion of the recording devices, which we can utilize in light of the necessities.
In the first place, we should investigate online devices.
1. Fast thread:
Quick String is the DevOps specialist's number one string dump examination instrument to investigate complex creation issues. This is an internet-based Java thread dump analyzer, We can transfer the thread dump as a document or we can straightforwardly reorder the thread dump.
Contingent upon the size, it will break down the string dump and shows the data as displayed in the screen capture.

Featureas:
- Machine Learning
- Android thread dump
- hs_err_pid analysis
- Core dump analysis
- Flame Graph
- Call Stack Tree
- Advanced Search
- Table View of thread states
2. Spotify Thread Dump Analyzer:
The Spotify thread Dump Analyzer is authorized under form 2.0 of the Apache permit. It is an internet-based instrument and acknowledges the thread dump as a document or we can straightforwardly reorder the thread dump. Contingent upon the size, it will dissect the string dump and shows the data as displayed in the screen capture.

3. Jstack review:
Jstack.review dissects java thread dumps from inside the program. This page is the client-side as it were.

4. Site 24×7:
This tool is essential for recognizing broken threads corrupting Java Virtual Machine(JVM) execution. Issues like stops, lock conflict, and the overabundance of central processor use by individual string dumps can be settled by picturing the conditions of individual string dumps.
The most extreme throughput from the application can be accomplished by amending the situation with each string given by the tool.

Offline Tools
1. JProfiler:
JProfiler is one of the most famous thread dump analyzers among Java designers. JProfiler's instinctive UI assists you with settling execution bottlenecks, nail down memory spills, and comprehending threading issues.

JProfiler upholds profiling on the accompanying stages:
- Windows
- macOS
- Linux
- FreeBSD
- Solaris
- AIX
- HP-UX
The following are a few highlights that go with JProfiler the top decision for profiling our applications on the JVM.
Features:
- Upholds information base profiling for JDBC, JPA, and NoSQL
- Support for Java endeavor release is additionally accessible
- Presents undeniable level data about RMI calls
- Heavenly investigation of memory spills
- Broad QA capacities
- The coordinated string profiler is firmly incorporated with the central processor 7. profiling sees.
- Support for stages, Ide's, and application servers.
2. IBM TMDA:
IBM thread and Monitor Dump Analyzer for Java (TMDA) is a device that permits distinguishing proof of hangs, halts, asset disputes, and bottlenecks in Java thread dumps. It is an IBM item yet the TMDA device is given with next to no guarantee or backing; in any case, they attempt to fix and upgrade the apparatus after some time.

3. ManageEngine:
ManageEngine applications administrator can assist with checking JVM Load and Non-Stack memory. We could design edges and be cautioned by email, SMS, and so forth, and guarantee a Java application is tuned well.

4. YourKit:
YourKit comprises of the underneath items called it as a Unit.
- Java Profiler - Completely highlighted low above profiler for Java EE and Java SE stages.
- YouMonitor - Execution checking and profiling of Jenkins, TeamCity, Gradle, Expert, Insect, JUnit, and TestNG.
- .NET Profiler - Simple to utilize execution and memory profiler for .NET structure.
In this cutting-edge world, thread dumps are as yet broken down in a dreary and manual mode i.e., you need to get hold of the DevOps group, request that they send you the string dumps, and then they will mail you the string dumps, then, at that point, you will transfer the dumps into a string dump examination instrument, then you need to apply your knowledge to dissect it. There is no automatic method for examining string dumps in a proactive way. Hence to wipe out this problem, fastthread.io is acquainting a Tranquil Programming interface with examine string dumps. With one line of Twist order, you can get your string dumps broken down in a flash.
Uses of Java thread dump analysis API:
1. Automatic Root cause Analysis:
The majority of DevOps conjures basic HTTP ping or APM tools to monitor the application's wellbeing. This ping is great to recognize regardless of whether the application is alive. APM apparatuses are perfect at illuminating that application's computer chip shot up by 'x%', memory usage expanded by 'y%', reaction time dropped by 'z' milliseconds.
It will not illuminate what made the central processor shoot up, what made memory usage increment, or what caused the reaction time to corrupt. On the off chance that you can design a Cron task to catch thread dumps/GC signs on an occasional span and summon our REST Programming interface, we apply our savvy designs and AI calculations to in a flash recognize the main driver of the issue.
Advantages:
- The majority of the DevOps summons a straightforward Http ping or APM instruments to screen the applications wellbeing. This ping is great to distinguish regardless of whether application is alive. APM apparatuses are perfect at illuminating that application's computer chip shot up by 'x%', memory usage expanded by 'y%', reaction time dropped by 'z' milliseconds. It will not illuminate what made the computer processor shoot up, what made memory use increment, what caused the reaction time to debase. In the event that you can design Cron task to catch string dumps/GC signs on an occasional span and summon our REST Programming interface, we apply our keen examples and AI calculations to immediately recognize the main driver of the issue.
- Not at all like APM apparatuses which professes to add under 3% of above, where as truly it adds various folds, excellence of this system is: It adds no above (or irrelevant above). Since whole investigation of the string dumps/GCeasy are finished on our servers and not on your creation servers.
2. Performance Tests:
At the point when you direct execution tests, you should accept thread dumps/GC signs on an occasional premise and get it broken down through the Programming interface. In the event that assuming that string count goes past an edge or on the other hand in the event that an excessive number of threads are Pausing or on the other hand on the off chance that any strings are Obstructed for a delayed period or lock isn't getting delivered or regular full GC exercises occurring or GC stop time surpasses limits, it necessities to get the permeability at that moment. It ought to be dissected before code raises a ruckus around town. In such a situation, this Programming interface will turn out to be exceptionally convenient.
3. Continuous Integration:
As a component of nonstop joining, it's profoundly urged to execute execution tests. thread dumps/GC Logs ought to be caught and it tends to be broken down utilizing the Programming interface. On the off chance that the Programming interface reports any issues, assemble can be fizzled. Along these lines, you can get the presentation debasement right during code commit time as opposed to getting it in execution labs or creation.
How to invoke Thread dump analysis API?
- Register with ushttp://fastthread.io/ft-registration.jsp. We will email you the Programming interface key. This is a one-time arrangement process. Note: On the off chance that you have bought an endeavour adaptation with a Programming interface http://fastthread.io/ft-pricing.jsp, you don't need to enlist. The programming interface key will be given to you as a feature of establishment guidance.
- Present HTTP demand on https://api.fastthread.io/fastthread-api?apiKey={API_KEY_SENT_IN_EMAIL}
- The body of the HTTP solicitation ought to contain the String dump that should be investigated. You can either send 1 thread dump or various string dumps in a similar solicitation.
- HTTP Reaction will be sent back in JSON design. JSON has a few significant details about the thread dump. The essential component to search in the JSON reaction is: "issue". The programming interface applies a few smart thread dump examinationhttps://blog.fastthread.io/category/thread-dump-patterns/ designs and in the event that it distinguishes any issues, it will be detailed in this "issue" component.
CURL command:
Expecting your thread dump document is situated in "./my-string dump.txt," then, at that point, Twist order to summon the Programming interface is:
curl -X POST --data-binary @./my-thread-dump.txt https://api.fastthread.io/fastthread-api?apiKey={API_KEY_SENT_IN_EMAIL} --header "Content-Type:text"
Compression:
Thread Dump is very enormous in size. For quick and productive handling, we prescribe you pack and send the String dump records. At the point when you are compacting the thread dump, you really want to pass the 'Content-Encoding' component in the HTTP Header component or in the URL boundary.
Say guess you are packing a thread dump record into a 'zip' design, then you can conjure the Programming interface with the HTTP header component.
curl -X POST --data-binary @./my-thread-dump.zip "https://api.fastthread.io/fastthread-api?apiKey={API_KEY_SENT_IN_EMAIL}" --header "Content-Type:text" --header "Content-Encoding:zip"
or on the other hand you can likewise summon the Programming interface with 'Content-Encoding' component in the URL boundary
curl -X POST --data-binary @./my-thread-dump.zip "https://api.fastthread.io/fastthread-api?apiKey={API_KEY_SENT_IN_EMAIL}&Content-Encoding=zip" --header "Content-Type:text"