故障诊断学习工具:在实践中学习 WebSphere 应用服务器故障诊断
2010-07-19 00:00:00 来源:WEB开发网查看原图(大图)
图 4. 动作面板
查看代码
"Dead Lock" 的动作面板中有两个动作按钮,"DeadLock Jsp" 按钮和 "Correct Jsp"。
用鼠标右键单击 "DeadLock Jsp" 按钮,在快捷菜单中选择 "Edit Action Button" ,在弹出的 Java 编辑器中我们可以查看或者编辑这个按钮所执行的 Java 代码,其代码如下:
清单 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
}
}
更多精彩
赞助商链接