使用 Problem Diagnostics Lab Toolkit 增强故障排除技能
2010-05-21 00:00:00 来源:WEB开发网清单 1. 按钮 DeadLock Jsp 执行的 Java 代码
synchronized (lock1) { // lock1 is defined in the "Methods and Static Variables" tab
Thread.sleep(5000);
ThreadMonitor.registerThreadStatus("blocked"); //It will be blocked here if the
//thread can not get the lock2
synchronized (lock2) {
ThreadMonitor.registerThreadStatus("running"); //It will continue to run if the
//thread can get the lock2
}
}
synchronized (lock2) { // lock2 is defined in the "Methods and Static Variables" tab
Thread.sleep(5000);
ThreadMonitor.registerThreadStatus("blocked"); //It will be blocked here if the
//thread can not get the lock1
synchronized (lock1) {
ThreadMonitor.registerThreadStatus("running"); //It will continue to run if the
//thread can get the lock1
}
}
清单 1 中的代码执行下面的动作:
获得一个全局锁:lock1。
休眠 5 秒钟。
获得另一个全局锁:lock2。
释放全局锁:lock1。
释放全局锁:lock2。
获得一个全局锁:lock2。
Tags:使用 Problem Diagnostics
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接