Mastering Arthas Thread Command for Deep Java Performance Insights
This article explains how the Arthas thread command can reveal detailed JVM thread information—including states, CPU usage, stack traces, and lock status—and provides a practical code demo to help Java developers monitor and diagnose performance issues effectively.
Arthas is a powerful open‑source Java diagnostic tool that excels in performance testing, analysis, and fault isolation for Java services. By combining Arthas with other JVM utilities, developers can gain comprehensive visibility into application behavior, making it an essential utility for backend performance engineering.
The thread sub‑command is a key feature for inspecting thread‑level details inside the JVM. It can display an overview of all threads, their current states, priorities, CPU consumption, stack traces, deadlock information, and lock status (object or class locks). Users can also group threads by state, set custom sampling intervals, and generate statistical reports to monitor CPU usage trends.
For quick reference, the official Arthas documentation is available at https://alibaba.github.io/arthas/. This page provides command syntax, options, and additional examples for deeper exploration.
Below is a self‑written demonstration that creates several threads performing repetitive work, which can be inspected with the thread command to observe concurrency behavior and performance metrics:
package com.fun;
import com.fun.frame.httpclient.FanLibrary;
class sdsync extends FanLibrary {
public static void main(String[] args) {
Thread thread1 = new Thread({
1000.times {
test(it + 10000)
}
});
Thread thread2 = new Thread({
1000.times {
test(it + 20000)
}
});
Thread thread3 = new Thread({
1000.times {
test(it + 30000)
}
});
Thread thread4 = new Thread({
1000.times {
test(it + 40000)
}
});
thread1.start();
thread2.start();
thread3.start();
thread1.join();
thread2.join();
thread3.join();
testOver();
}
static void test(int i) {
output(Thread.currentThread().getName() + "开始!----$i");
synchronized (sdsync.class) {
sleep(1000);
}
output(Thread.currentThread().getName() + "结束!-----${i}");
}
}Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
