[concurrency-interest] synchronized block expansion

Doug Lea dl at cs.oswego.edu
Thu Feb 9 07:56:24 EST 2006


studdugie wrote:
> Jeremy said:
>    Although it is legal to expand a synchronized section, it is not legal
>    to expand it over another lock acquisition.
> 
> That was the root of my confusion because I didn't know the JVM knew
> that there are other types of locking beside its native monitor
> aquisitions. I was concerned that it would see CountDownLatch as just
> another class, completely oblivious to what CountDownLatch.await would
> do.
> 

For the most part, the low-level instruction generation in a JVM
doesn't know much about locks per se, but it must know the memory
model, and the fact volatile/atomic reads and writes (and compareAndSets)
have ordering constraints. So a java.util.concurrent synchronizer
based on atomics etc and a builtin lock (also based on atomics etc, but
using internally generated instructions) are handled in about the
same way, and must work correctly wrt each other.

-Doug



More information about the Concurrency-interest mailing list