当前位置:网站首页>Arthas thread command locates thread deadlock
Arthas thread command locates thread deadlock
2022-06-23 07:15:00 【qq_ thirty-seven million two hundred and seventy-nine thousand 】
Scenario simulating deadlock
public class Deadlock {
private static Object obj1 = new Object();
private static Object obj2 = new Object();
public static void main(String[] args) {
new Thread(() -> {
System.out.println(" Threads 1 perform ");
synchronized (obj1) {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (obj2) {
}
}
}, "t1").start();
new Thread(() -> {
System.out.println(" Threads 2 perform ");
synchronized (obj2) {
synchronized (obj1) {
}
}
}, "t2").start();
System.out.println(" completion of enforcement ");
}
}
adopt thread Command positioning
1, Use it directly ”thread“ command , Output thread Statistics . among :BLOCKED Indicates the number of threads currently blocked .
[[email protected]]$ thread
Threads Total: 26, NEW: 0, RUNNABLE: 8, BLOCKED: 2, WAITING: 4, TIMED_WAITING: 2, TERMINATED: 0, Internal threads: 10
ID NAME GROUP PRIORITY STATE %CPU DELTA_TIM TIME INTERRUPT DAEMON
2 Reference Handler system 10 WAITING 0.0 0.000 0:0.000 false true
3 Finalizer system 8 WAITING 0.0 0.000 0:0.000 false true
4 Signal Dispatcher system 9 RUNNABLE 0.0 0.000 0:0.000 false true
5 Attach Listener system 5 RUNNABLE 0.0 0.000 0:0.031 false true
14 arthas-timer system 5 WAITING 0.0 0.000 0:0.015 false true
17 arthas-NettyHttpTelnetBootstr system 5 RUNNABLE 0.0 0.000 0:0.015 false true
18 arthas-NettyWebsocketTtyBoots system 5 RUNNABLE 0.0 0.000 0:0.015 false true
19 arthas-NettyWebsocketTtyBoots system 5 RUNNABLE 0.0 0.000 0:0.015 false true
20 arthas-shell-server system 5 TIMED_WA 0.0 0.000 0:0.000 false true
21 arthas-session-manager system 5 TIMED_WA 0.0 0.000 0:0.000 false true
22 arthas-UserStat system 5 WAITING 0.0 0.000 0:0.000 false true
24 arthas-NettyHttpTelnetBootstr system 5 RUNNABLE 0.0 0.000 0:0.109 false true
25 arthas-command-execute system 5 RUNNABLE 0.0 0.000 0:0.015 false true
10 t1 main 5 BLOCKED 0.0 0.000 0:0.000 false false
11 t2 main 5 BLOCKED 0.0 0.000 0:0.000 false false
12 DestroyJavaVM main 5 RUNNABLE 0.0 0.000 0:0.156 false false
2, perform “thread -b” command , Find out which threads are currently blocking other threads , That is, the culprit of deadlock
[[email protected]]$ thread -b
"t1" Id=10 BLOCKED on [email protected] owned by "t2" Id=11
at test.Deadlock.lambda$main$0(Deadlock.java:24)
- blocked on [email protected]
- locked [email protected] <---- but blocks 1 other threads!
at test.Deadlock$$Lambda$1/250421012.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
notes : The above command directly outputs Thread causing deadlock ID, And specific code locations , And the total number of threads blocked by the current thread :“<—- but blocks 1 other threads!“.
3, Other thread commands :
thread –all, Show all threads ;
thread id, Show the run stack of the specified thread ;
thread –state: View threads in the specified state , Such as :thread –state BLOCKED;
thread -n 3: Show the current busiest front N Thread and print stack ;
边栏推荐
- Nacos适配oracle11g-建表ddl语句
- Analysis of personalized learning progress in maker Education
- .h5文件忘记数据库名字,使用h5py打印
- The List
- MySQL(四) — MySQL存储引擎
- About SQL: is there a way to fill in the null value in the field without adding fields on the basis of the original fields
- 313. super ugly number
- Advanced drawing skills of Excel lecture 100 (VIII) -excel drawing WiFi diagram
- 深度学习系列47:styleGAN总结
- Flannel 工作原理
猜你喜欢
随机推荐
307. area and retrieval - array modifiable
Spock约束-调用频率/目标/方法参数
309. 最佳买卖股票时机含冷冻期
SSM integration
Xshell7 Download
PSP代码实现
303. region and retrieval - array immutable
322. 零钱兑换
Endnote20 tutorial sharing (unfinished
312. 戳气球
数据统计与分析基础 实验一 基本语法及运算
NTU-RGBD数据集下载及数据格式解析
1161 Merging Linked Lists
别找了诸位 【十二款超级好用的谷歌插件都在这】(确定不来看看?)
Nacos适配oracle11g-建表ddl语句
898. subarray bitwise OR operation
Technical article writing guide
SSM整合
TensorFlow中的数据类型
Interpreting the spirit of unity and cooperation in maker Education









