当前位置:网站首页>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 ;
边栏推荐
猜你喜欢

Deeplab V3 code structure diagram

20BN-Jester完整数据集下载

excel高级绘图技巧100讲(八)-Excel绘制WIFI图

对二进制的某一位操作

js 判断两个数组增加和减少的元素

yolov5检测小目标(附源码)

Project_ Filter to solve Chinese garbled code

聚焦行业,赋能客户 | 博云容器云产品族五大行业解决方案发布

Analyzing the creation principle in maker Education
![[system] right click the desktop icon. After turning around, the Explorer will crash and the desktop will be refreshed](/img/aa/0189beb065fa0d4b625390793cb79b.png)
[system] right click the desktop icon. After turning around, the Explorer will crash and the desktop will be refreshed
随机推荐
901. stock price span
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
Xshell7 Download
char和varchar区别
用户态和内核态
Tp6+redis+think-queue+supervisor implements the process resident message queue /job task
SSM integration
U-Net: Convolutional Networks for Biomedical Image Segmentation
315. 计算右侧小于当前元素的个数
.h5文件忘记数据库名字,使用h5py打印
300. 最长递增子序列
Endnote20 tutorial sharing (unfinished
产品-Axure9(英文版),原型设计 制作下拉二级菜单
Spock约束-调用频率/目标/方法参数
Nacos适配oracle11g-修改Nacos源码
初始化层实现
NTU-RGBD数据集下载及数据格式解析
295. median data flow
898. 子数组按位或操作
深度学习系列46:人脸图像超分GFP-GAN