Fully featured low overhead profiler for Java EE and Java SE platforms.
Easy-to-use performance and memory .NET profiler for Windows, Linux and macOS.
Secure and easy profiling in cloud, containers and clustered environments.
Performance monitoring and profiling of Jenkins, Bamboo, TeamCity, Gradle, Maven, Ant and JUnit.

Thread profiling

Goals of thread profiling

Thread profiling provides insights into the behavior and interactions of threads in a Java application, helping to identify concurrency issues that may impact performance. By periodically recording thread states and call stacks, it enables analysis of state distribution, detection of bottlenecks or deadlocks, estimation of CPU usage, and identification of frozen threads. This low-overhead process offers valuable information for optimizing thread interactions and resource utilization without significantly affecting application performance.

Thread profiling modes

States and stacks mode

Periodically record states and stacks of running threads. This information makes it possible to build a timeline of thread states, as well as to estimate CPU usage and enables frozen thread detection.

Retrieving thread states and stacks incurs low overhead, primarily because these operations are conducted infrequently. This overhead is significantly lower when compared to CPU profiling.

States mode

Periodically record only the states of running threads. Thread stacks are not recorded and the CPU usage estimation will be unavailable, but profiling overhead will be lower.

Controlling thread profiling

Profiler UI

When the profiler is connected to the profiled application, the toolbar contains the following exception profiling controls:

Toolbar Button Description
Start thread profiling button Stop thread profiling button Start/Stop thread profiling.
Clear thread profiling results button Clear thread profiling results.

When thread profiling is started, previous results are cleared automatically.

Agent startup options

Thread profiling collects states and stacks by default. Interval for collecting this data is set to 1 second and limited to 1 hour. However, this can be adjusted with startup options threads, telemetry_period, telemetry_limit.

HTTP API

For users requiring remote control or automation within their profiling workflows, YourKit Java Profiler offers control over the thread profiling through HTTP API endpoints. The documentation outlines startThreadProfiling, stopThreadProfiling and resetThreadProfiling methods available for this purpose.

Java API

The YourKit Java Profiler also provides a Java API for deep integration with Java applications. The com.yourkit.api.controller.v2.Controller includes methods for starting, stopping, and resetting the thread profiling, similar to the toolbar buttons.

Threads tab

Thread profiling tab offers a suite of tools to analyze thread behavior, providing insights into performance and concurrency issues. These views help in understanding thread interactions:

  • Telemetry charts showing thread-related performance metrics over time.
  • Thread states timeline of thread state transitions, such as running, waiting, blocked, and more.
  • Deadlocks detection for identifying deadlocks between Java threads.
  • Frozen threads helps identify threads that are unresponsive or stuck.

Threads in HPROF snapshot

HPROF snapshot can optionally contain information about running threads, their stacks, and their states. In the Threads tab you can examine the list of threads and their stacks.

If an OutOfMemoryError occurred in the program during the invocation of a Java object constructor <init>, YourKit Java Profiler will locate this thread and highlight it with a special OutOfMemoryError icon.

Thread in PROF snapshot

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.