除了常见的JVisualVM ,JConsole。
还有Arthas。
Arthas 是 Alibaba 在 2018 年 9 月开源的 Java 诊断工具。支持 JDK6+, 采用命令行交互模式,可以方便的定位和诊断 线上程序运行问题。Arthas 官方文档十分详细,详见:https://alibaba.github.io/arthas
这个Athas在linux和window下都能用。就下载一个arthas‐boot.jar。
下载方法,自行去找。太多了博文了。
今天,我们先准备一个能使CPU冲高,死锁的程序。
CUP冲高核心代码:
public static void cpuHigh() {
new Thread(() -> {
while (true) {
} }).start();
}
死锁核心代码:
/**
* * 死锁
*/
private static void deadThread() {
/** 创建资源 */
Object resourceA = new Object();
Object resourceB = new Object();
// 创建线程 5
Thread threadA = new Thread(