[concurrency-interest] Re: synchronized vs ReentrantLock semantic

David Holmes dholmes at dltech.com.au
Tue Jun 14 00:50:03 EDT 2005


> Dawid Kurzyniec writes:
> I agree with Greg that perhaps the javadoc should be more verbose on
> this. Including the spec of AQS. As it is, it is perfectly accurate but
> requires the reader to have read and understood the JVM spec, in
> particular the semantics of monitorEnter/monitorExit and the JMM.

I don't think there is any problem with the AQS docs - it is written in
terms of behaviour of volatiles and to understand a volatile you have to
understand the JMM - JLS 8.3.1.4 is quite clear on that.

I do agree about Lock however. The use of "monitorEnter" and "monitorExit"
is quite unfamiliar to most language users. Even the JLS only talks about
monitors in Chapter 17; it doesn't mention them at all in the discussion of
the synchronized statement in 14.19 !

And anytime the docs mention memory semantics there should really be a
reference to JLS Chapter 17. We should have a standard phrase like:

"In terms of the Java Memory Model (see "The Java Language Specification",
Chapter 17) the memory synchronization effect of this method is ..."

Cheers,
David Holmes



More information about the Concurrency-interest mailing list