https://arthas.aliyun.com/doc/
1
2
3
4
5
6
7
| baoguo@MacBook-Pro software % curl -O https://arthas.aliyun.com/arthas-boot.jar
baoguo@MacBook-Pro software % java -jar arthas-boot.jar
[arthas@701]$ dashboard
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
import java.util.HashSet;
public class ArthasTest {
private static HashSet hashSet = new HashSet();
public static void main(String[] args) {
cpuHigh();
deadThread();
addHashSetThread();
}
public static void addHashSetThread() {
new Thread(() -> {
int count = 0;
while (true) {
try {
hashSet.add("count" + count);
Thread.sleep(10000);
count++;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
}
public static void cpuHigh() {
new Thread(() -> {
while (true) {
}
}).start();
}
private static void deadThread() {
Object resourceA = new Object();
Object resourceB = new Object();
Thread threadA = new Thread(() -> {
synchronized (resourceA) {
System.out.println(Thread.currentThread() + " get ResourceA");
try {
Thread.sleep(1000);
}catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(Thread.currentThread() + "waiting get resourceB");
synchronized (resourceB) {
System.out.println(Thread.currentThread() + "get resourceB");
}
}
});
Thread threadB = new Thread(() -> {
synchronized (resourceB) {
System.out.println(Thread.currentThread() + " get ResourceB");
try {
Thread.sleep(1000);
}catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(Thread.currentThread() + "waiting get resourceA");
synchronized (resourceA) {
System.out.println(Thread.currentThread() + "get resourceA");
}
}
});
threadA.start();
threadB.start();
}
}
|
1
2
3
4
5
6
7
8
| [arthas@5516]$ dashboard
[arthas@5516]$ thread 10
"Thread-0" Id=10 RUNNABLE
at ArthasTest.lambda$cpuHigh$1(ArthasTest.java:29)
at ArthasTest$$Lambda$1/531885035.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
[arthas@5634]$ jad ArthasTest -- 反编译服务端代码,可以知道代码有没有发布成功
|