Re: JavaMemoryModel: Idiom for safe, unsynchronized reads

From: Joshua Bloch (jbloch@eng.sun.com)
Date: Mon Jun 28 1999 - 15:01:25 EDT


-----Original Message-----

From: Doug Lea <dl@altair.cs.oswego.edu>

>Consider the use of simple classes like String and Integer. One of the
>original motivations for declaring these classes as immutable wass for
>the sake of thread safety.

   Yep.

>
>Should there be two versions, one of which uses synch in its constructor
>and one not? Or should people put synch blocks only when constructing
>those that the believe might be accessible across threads?

   It's not enough to synch the constructor! An unlock action in the writer
without a lock action in the reader is useless.

>No answers along these lines strike me as tolerable.
>
>I think the only choice here is for the semantics to guarantee safety.

    I agree wholeheartedly.

                      Josh

-------------------------------
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:13 EDT