[concurrency-interest] Re: When do you use wait/notify?

Ernst, Matthias matthias.ernst@coremedia.com
Mon, 26 Jan 2004 22:14:01 +0100


This is a multi-part message in MIME format.

------_=_NextPart_001_01C3E451.523C9930
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Larry:
> Seeing which threads have which locks?  I imagine the JPDA/JDI/JVMDI
> will continue to have the capability to do the equivalent.  And maybe
> the profiling thing, JSR-163?

 =20
Actually that's what I tried to ask in one of my last emails. If I judge =
correctly there is no direct connection from a thread to a lock object; =
actually cannot be, since the lock is entirely an application-level =
concept. Threads only know of being parked and unparked.=20
=20
=20
A thread dump looks as follows:
=20
"Thread-1" prio=3D5 tid=3D0x00943468 nid=3D0xd10 waiting on condition =
[0x0154f000..0x0
154fa98]
        at java.lang.Thread.sleep(Native Method)
        at LockTest.doit(LockTest.java:13)
        at LockTest$2.run(LockTest.java:35)
=20
"Thread-0" prio=3D5 tid=3D0x00936068 nid=3D0xaf0 runnable =
[0x0144f000..0x0144fb18]
        at sun.misc.Unsafe.park(Native Method)
        at =
java.util.concurrent.locks.LockSupport.park(LockSupport.java:118)
        at =
java.util.concurrent.locks.ReentrantLock.waitForLock(ReentrantLock.java:4=
84)
        at =
java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:600)
        at LockTest.doit(LockTest.java:11)
        at LockTest$1.run(LockTest.java:24)
=20
Maybe #park could take an arbitrary argument that denotes the reason for =
being parked --- which would be accessible from JVMTI and maybe visible =
in a thread dump. In case of a lock, e.g., a thread dump could then =
display the lock's oid, owner and wait queue.
=20
=20
=20
BTW, I'm not able to run the current JSR 166 jar:
=20
C:\Documents and Settings\Matthias\j2se 1.5>\j2sdk1.5.0\bin\java =
-Xbootclasspath
/p:\tmp\jsr166.jar -classpath out LockTest
Error occurred during initialization of VM
java.lang.NoClassDefFoundError: sun/misc/JavaLangAccess
=20
Matthias
=20

------_=_NextPart_001_01C3E451.523C9930
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">=0A=
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">=0A=
<HTML>=0A=
<HEAD>=0A=
=0A=
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.6944.0">=0A=
<TITLE>[concurrency-interest] Re: When do you use wait/notify?</TITLE>=0A=
</HEAD>=0A=
<BODY>=0A=
<DIV id=3DidOWAReplyText24097 dir=3Dltr>=0A=
<DIV dir=3Dltr><FONT face=3D"Courier New" color=3D#000000 size=3D2>=0A=
<DIV dir=3Dltr>Larry:</DIV>=0A=
<DIV dir=3Dltr>&gt; Seeing which threads have which locks?&nbsp; I =
imagine the =0A=
JPDA/JDI/JVMDI<BR>&gt; will continue to have the capability to do the =0A=
equivalent.&nbsp; And maybe<BR>&gt; the profiling thing, =
JSR-163?<BR></DIV>=0A=
<DIV dir=3Dltr>&nbsp;=0A=
<DIV dir=3Dltr><FONT face=3D"Courier New" color=3D#000000 =
size=3D2>Actually that's what =0A=
I tried to ask in one of my last emails. If I judge correctly there is =
no direct =0A=
connection from a thread to a lock object; actually cannot be, since the =
lock is =0A=
entirely an application-level concept. Threads only know of being parked =
and =0A=
unparked. </FONT></DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV></DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr>A thread dump looks as follows:</DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr>"Thread-1" prio=3D5 tid=3D0x00943468 nid=3D0xd10 waiting =
on condition =0A=
[0x0154f000..0x0<BR>154fa98]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; at =0A=
java.lang.Thread.sleep(Native =0A=
Method)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at =0A=
LockTest.doit(LockTest.java:13)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; at =0A=
LockTest$2.run(LockTest.java:35)</DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr>"Thread-0" prio=3D5 tid=3D0x00936068 nid=3D0xaf0 runnable =0A=
[0x0144f000..0x0144fb18]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
at =0A=
sun.misc.Unsafe.park(Native =0A=
Method)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at =0A=
java.util.concurrent.locks.LockSupport.park(LockSupport.java:118)<BR>&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =0A=
at =0A=
java.util.concurrent.locks.ReentrantLock.waitForLock(ReentrantLock.java:4=
84)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =0A=
at =
java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:600)</DI=
V>=0A=
<DIV dir=3Dltr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at =0A=
LockTest.doit(LockTest.java:11)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; at =0A=
LockTest$1.run(LockTest.java:24)</DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr><FONT face=3D"Courier New" size=3D2>Maybe #park could =
take an arbitrary =0A=
argument that denotes the reason for being parked --- which would be =
accessible =0A=
from JVMTI and maybe visible in a thread dump. In case of a lock, e.g., =
a thread =0A=
dump could then display the lock's oid, owner and wait =
queue.</FONT></DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr>BTW, I'm not able to run the current JSR 166 =0A=
jar:</DIV></FONT></DIV></DIV>=0A=
<DIV dir=3Dltr>&nbsp;</DIV>=0A=
<DIV dir=3Dltr><FONT face=3D"Courier New" size=3D2>C:\Documents and =0A=
Settings\Matthias\j2se 1.5&gt;\j2sdk1.5.0\bin\java =0A=
-Xbootclasspath<BR>/p:\tmp\jsr166.jar -classpath out LockTest<BR>Error =
occurred =0A=
during initialization of VM<BR>java.lang.NoClassDefFoundError: =0A=
sun/misc/JavaLangAccess</FONT></DIV>=0A=
<DIV dir=3Dltr><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV dir=3Dltr><FONT face=3D"Courier New" size=3D2>Matthias</FONT></DIV>=0A=
<DIV dir=3Dltr><FONT size=3D3></FONT>&nbsp;</DIV>=0A=
=0A=
</BODY>=0A=
</HTML>
------_=_NextPart_001_01C3E451.523C9930--