RE: JavaMemoryModel: RE: Question on memory models

From: David Holmes (dholmes@ics.mq.edu.au)
Date: Wed Jun 30 1999 - 23:29:18 EDT


> [mailto:owner-javamemorymodel@cs.umd.edu]On Behalf Of Sarita Adve
> - I also think more thought needs to be given to whether this
> is a desirable constraint at all. My personal bias is with Raymie's
> position - If we expect programmers to synchronize for general writes,
then
> why not for initialization writes?

I also, generally support Raymies position - I don't believe that all of
the initialisation scenarios considered should be made correct with out
synchronisation. However construction is a special case. An object does not
exist until it has been constructed and until it has been constructed no
one should be able to see it. Once it has been constructed then anyone who
can see it should see it in its constructed form (or some later form if
mutation is possible)- not some intermediate mish-mash of bits. Now we know
we can shoot ourselves in the foot by publishing 'this' during construction
but even then we should see the object at some state of its initialisation,
not some random mixed state.

The essence of this is that improper synchronisation should not allow the
language rules to be broken. I think this is very important - especially
when immutable objects are involved (ala Doug and Josh's arguments).
However, I too am concerned about the cost of achieving this on systems
where action is needed to make it happen.

> Also, I worry that no matter how we state this
> exception to the general rule of needing synchronization, there would be
> other cases that are almost similar but are not included in the
> exception and would encourage confusion and bugs.

I agree that this is a problem - the fine line between different cases is
indeed very fine. That is why I make a distinction between construction and
general initialisation (say via a factory method). I don't see the new
rules as a means of advertising ways to try and avoid synchronisation,
rather they are a safety-net to ensure language rules are not broken when
synchronisation is not used.

David Holmes

-------------------------------
This is the JavaMemoryModel mailing list, managed by Majordomo 1.94.4.

To send a message to the list, email JavaMemoryModel@cs.umd.edu
To send a request to the list, email majordomo@cs.umd.edu and put
your request in the body of the message (use the request "help" for help).
For more information, visit http://www.cs.umd.edu/~pugh/java/memoryModel



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