From: Godmar Back (gback@cs.utah.edu)
Date: Tue Jan 26 1999 - 12:17:13 EST
With the latest patch, you'll get this output when running the
program below.
Unfortunately, with stderr nonblocking, fflush doesn't always work right,
so sometimes some of the output gets cut off.
-----------------------------------------------------------------------
Holding B, grabbing A...
Holding A, grabbing B...
Dumping dynamic locks:
lock@0x325c20 java.lang.Class `DeadLock' held by `Thread-1'
.hd=0x430010 .ct=1 .mx=0x183f90 .cv=0x183fa0
lock@0x380d58 java.lang.String `resource A' held by `Thread-0'
.hd=0x413010 .ct=1 .mx=0xdb390 .cv=0xdb3a0
Dumping static locks:
&gcman held by `gc'
.hd=0x3d5010 .ct=0 .mx=0x34f5d0 .cv=0x34f5e0
&finman held by `finaliser'
.hd=0x3cc010 .ct=0 .mx=0x34f5b0 .cv=0x34f5c0
&thread_start_lock held by `noone'
.hd=0x0 .ct=0 .mx=0x34f590 .cv=0x34f5a0
&translatorlock held by `noone'
.hd=0x0 .ct=0 .mx=0x183850 .cv=0x183860
&classLock held by `noone'
.hd=0x0 .ct=0 .mx=0xdb2f0 .cv=0xdb300
&jarlock held by `noone'
.hd=0x0 .ct=0 .mx=0xdb250 .cv=0xdb260
&classHashLock held by `noone'
.hd=0x0 .ct=0 .mx=0xdb210 .cv=0xdb220
&utf8Lock held by `noone'
.hd=0x0 .ct=0 .mx=0xdb1f0 .cv=0xdb200
&stringLock held by `noone'
.hd=0x0 .ct=0 .mx=0xdb1d0 .cv=0xdb1e0
&gc_lock held by `noone'
.hd=0x0 .ct=0 .mx=0x2007f36c .cv=0x2007f374
Dumping live threads:
`Thread-1' tid 0x430010, status SUSPENDED flags
blockqueue 0xdb394 (0x430010->|)
`Thread-0' tid 0x413010, status SUSPENDED flags
blockqueue 0x183f94 (0x413010->|)
`gc' tid 0x3d5010, status SUSPENDED flags DONTSTOP
blockqueue 0x34f5e0 (0x3d5010->|)
`finaliser' tid 0x3cc010, status SUSPENDED flags DONTSTOP
blockqueue 0x34f5c0 (0x3cc010->|)
Deadlock: all threads blocked on internal events
Abort
-----------------------------------------------------------------------
-----------------------------------------------------------------------
public class DeadLock implements Runnable
{
int what;
static String A = "resource A";
static Class B = DeadLock.class;
static String C = "helper";
DeadLock(int i)
{
this.what = i;
}
public void run()
{
if (what == 1) {
// grab A
synchronized (A) {
synchronized (C) {
try {
C.wait();
} catch(InterruptedException e) {}
}
System.out.println("Holding A, grabbing B...");
// try to grab B
synchronized (B) {
}
}
} else {
// grab B
synchronized (B) {
// tell the other thread we have B
synchronized (C) {
C.notify();
}
System.out.println("Holding B, grabbing A...");
// try to grab A
synchronized (A) {
}
}
}
}
public static void main(String []av)
{
new Thread(new DeadLock(1)).start();
new Thread(new DeadLock(2)).start();
}
}
-----------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:49 EDT