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
}
}