RE: JavaMemoryModel: FWD: Question regarding nested synchronized blocks

From: Bill Pugh (
Date: Tue Apr 23 2002 - 05:57:52 EDT

At 12:29 PM +1000 4/23/02, David Holmes wrote:
>So if 8 is just 'n', for what value of 'n' does this screw up my
>synchronisation policy? And again how do I know what value of 'n' the VM
>will use.
>I'm very uncomfortable with a situation where the model says that the VM can
>completely break my code, but implementers tell me, don't worry we probably
>won't do that in practice. Just too ad-hoc for me.
>Remind me again *why* we are letting this happen? :)

There was a discussion a while back on fairness, and the general
consensus was that Java didn't mandate any kind of fairness guarantee
at all. I wasn't thrilled about that decision, but that seems to be
the way things got decided.

For example, in some JVMs, thread/context switches only happen on
uniprocesssors only under compiler control. There are no requirements
about the points at which the compiler must allow a context switch.

We could try to open this up again, but I suspect the result would be the same.

One thing on fairness that resolves some of my concerns. I think we
can say that some JVMs may be fair, and that no transformation of
source code or bytecode upstream of the JVM on which the code is to
be executed is allowed to perform any transformations that would
eliminate the possibility of a fair execution of the program.

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:39 EDT