[concurrency-interest] JSR 166 locks

Ernst, Matthias matthias.ernst@coremedia.com
Sat, 24 Jan 2004 12:09:50 +0100


This is a multi-part message in MIME format.

------_=_NextPart_001_01C3E26A.96083EA1
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,
=20
I have a few remarks about locking:
=20
* Could one say that LockSupport#park/unpark are semantically equivalent =
to Thread.currentThread().wait() / someThread.notify() ?
* I've been reading a great deal of papers around the days of EVM/early =
Hotspot about the most efficient way to implement Java monitors (thin =
locks, ...). The obvious difference, of course, is that JSR 166 does not =
allow synchronization on every Java object, i.e. the whole space/object =
header issues do not arise. Besides that, how do the two implementations =
compare ? Now that CAS and volatile/mbars are available, would you say =
that the new implementations are up to par with their "native" =
equivalents ?
* I've been using the util.concurrent package for a long time now, and =
there is one big drawback of Java-defined locking primitives: it is =
impossible to spot locking states in thread dumps. Your application =
deadlocks and you cannot see why. A parked thread has no real =
association to a lock object anymore. Do you have any plans on VM =
support for that ? The only option I see is to iterate over all lock =
objects in the heap and look at their owner -- and that doesn't give me =
the locking order. Maybe I'll give it a shot with the new JVMTI. Well, =
all the nice synchronization constructs should save me from deadlocks in =
the first place ...
* Thank you for not throwing InterruptedException from 'lock'.
=20
Best
Matthias
=20
--=20
Matthias Ernst
CoreMedia - The Content Technology Experts


------_=_NextPart_001_01C3E26A.96083EA1
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML =
DIR=3Dltr><HEAD><META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1"></HEAD><BODY>=0A=
<DIV id=3DidOWAReplyText45499 dir=3Dltr>=0A=
<DIV dir=3Dltr>=0A=
<DIV><FONT face=3D"Courier New" color=3D#000000 size=3D2>Hi,</FONT></DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2>I have a few remarks about =0A=
locking:</FONT></DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2>* Could one say that =0A=
LockSupport#park/unpark are semantically equivalent to =0A=
Thread.currentThread().wait() / someThread.notify() ?</FONT></DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2>* I've been reading a great =
deal of papers =0A=
around the days of EVM/early Hotspot about the most efficient way to =
implement =0A=
Java monitors (thin locks, ...). The&nbsp;obvious difference, of course, =
is that =0A=
JSR 166 does not allow synchronization on every Java object, i.e. the =
whole =0A=
space/object header&nbsp;issues do not arise. Besides that, how do the =
two =0A=
implementations compare ? Now that CAS and volatile/mbars are available, =
would =0A=
you say that the new implementations are up to par with their "native" =0A=
equivalents ?</FONT></DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2>* I've been using the =
util.concurrent =0A=
package for a long time now, and there is one big drawback of =
Java-defined =0A=
locking primitives: it is impossible to spot locking states in thread =
dumps. =0A=
Your application deadlocks and you cannot see why. A parked thread has =
no real =0A=
association to a lock object anymore. Do you have any plans on VM =
support for =0A=
that ? The only option I see is to iterate over all lock objects in the =
heap and =0A=
look at their owner -- and that doesn't give me the locking order. Maybe =
I'll =0A=
give it a shot with the new JVMTI. Well, all the nice synchronization =
constructs =0A=
should save me from deadlocks in the first place ...</FONT></DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2>* Thank you for not throwing =0A=
InterruptedException from 'lock'.</FONT></DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2>Best</FONT></DIV>=0A=
<DIV><FONT face=3D"Courier New" size=3D2>Matthias</FONT></DIV>=0A=
<DIV>&nbsp;</DIV>=0A=
<DIV>-- </DIV></DIV></DIV>=0A=
<DIV id=3DidSignature7184 dir=3Dltr>=0A=
<DIV><B><FONT face=3D"Courier New" color=3Dgray size=3D2><SPAN =
lang=3DEN-GB =0A=
style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: =
'Courier New'">Matthias =0A=
Ernst<BR></SPAN></FONT></B><B><FONT face=3D"Courier New" color=3Dgray =
size=3D2><SPAN =0A=
lang=3DEN-GB =0A=
style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: =
'Courier New'">CoreMedia =0A=
- The Content Technology Experts<BR></SPAN></FONT></B><B><FONT =0A=
face=3D"Courier New" color=3Dgray size=3D2><SPAN lang=3DEN-GB =0A=
style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: =
'Courier New'"></DIV></SPAN></FONT></B></DIV></BODY></HTML>
------_=_NextPart_001_01C3E26A.96083EA1--