threads command analyzes sample distribution across threads, showing which threads are active and consuming resources. It supports optional grouping to aggregate thread pools.
Usage
What It Shows
A table of threads ranked by sample count, showing:- Thread name
- Sample count
- Percentage of total samples
--group, shows:
- Thread group name (normalized from thread pool patterns)
- Number of threads in the group
- Aggregate sample count
- Percentage of total samples
Flags
Limit output rows. Default
0 means unlimited (show all threads).Group threads by normalized name, aggregating thread pools. Useful for understanding thread pool behavior.Grouping rules:
- Removes numeric segments:
pool-1-thread-2→pool-thread - Strips trailing digits:
worker-thread-5→worker-thread - Handles common separators:
-,_,# - Examples:
http-nio-8080-exec-1→http-nio-execGC Thread#54→GC ThreadCompilerThread0→CompilerThread
Shared Flags
Event type:
cpu, wall, alloc, lock, or hardware counter name.Filter to threads containing this substring (applied before grouping).
Start of time window (JFR only).
End of time window (JFR only).
Remove idle leaf frames from analysis.
Examples
Basic Thread List
Grouped by Thread Pool
Top Threads Only
Top Groups Only
Filter Specific Threads
Wall-Clock Thread Analysis
Compare CPU vs Wall by Thread
Run both and compare:Threads with high wall% but low CPU% are likely blocked on I/O or locks. Threads with similar CPU% and wall% are compute-bound.
Reading the Output
Individual Threads
Grouped Threads
http-nio-exec thread pool has 24 threads that collectively account for 9,432 samples (78.3% of total).
Thread Grouping Rules
Grouping normalizes thread names by:- Splitting on separators:
-,_,# - Removing numeric segments:
1,42,8080 - Trimming trailing digits:
thread5→thread
| Original | Grouped |
|---|---|
pool-1-thread-2 | pool-thread |
http-nio-8080-exec-1 | http-nio-exec |
GC Thread#54 | GC Thread |
CompilerThread0 | CompilerThread |
worker-5 | worker |
No Thread Info
If the profile lacks thread information:- Collapsed-stack text files (no metadata)
- Some pprof profiles
- Profiles with thread tracking disabled
When to Use
Thread Pool Sizing
Identify if thread pools are over/under-provisioned
Workload Distribution
See if work is balanced across threads
Blocking Detection
Compare CPU vs wall events to find blocked threads
GC Analysis
See how much time GC threads consume