Quick start for Java thread stack analysis

Updated at:

This topic describes how to use the Java thread stack analysis feature in ATP to analyze thread activity in a Java application.

1. Generate a data source and upload it to ATP

a. Use the `jstack` command from the Java Development Kit (JDK) to create a thread snapshot of your Java application:

# Create a thread snapshot and save it to jstack.log
$ jstack <process_id> > jstack.log

b. After the item is created, upload the file to ATP for analysis.

For more information, see 2.2 Generate a Java stack file.

2. Analyze the thread stack with ATP

This topic uses the spring-petclinic application as an example. After the application starts, you can create a thread stack snapshot and upload it to ATP for analysis.

The following describes the different views.

View Options

Description

Basic information

The Basic information view contains the following information:

  • Snapshot creation time (not the upload time)

  • JVM version

  • Number of Java Native Interface (JNI) references

  • Number of thread deadlocks

This view also classifies all threads by state and type.

Thread information

The Thread Information view displays information about all threads:

  • Stack

  • CPU and other resources

Note

Some information, such as CPU and Elapsed time, is available only in later JDK versions.

Search for threads by fields such as thread name and thread ID.

Thread pools

The Thread pools view classifies all threads by name and shows their distribution by state. Use this view to help troubleshoot thread leak issues.

Method hot spots

The Method hot spots view uses a flame graph to visualize all thread stacks. This helps you analyze potential hot spots in the application.

Note

The flame graph aggregates data by the number of stacks. A wider bar does not always mean a hot spot method. For example, it is normal for many threads to be blocked on the same Java method.

3. Conclusion

The Java thread stack analysis feature in ATP helps you analyze thread activity within your application.