RE: JavaMemoryModel: No "Spooky errors at a distance"

From: David Holmes (dholmes@dltech.com.au)
Date: Thu Mar 07 2002 - 17:18:40 EST


Bill Pugh wrote:
> Now, I will argue feature 1: assuming you aren't playing games with
> ThreadLocals or thread identity, using (2) should never be worse than
> using (1). If using (2) could be worse, Executors become unattractive
> and debugging nearly impossible.

Agreed.

> In particular, say that
> a) some other thread has published a reference to an object x while
> x is being constructed
>
> b) r1 loads a reference to x in a way that doesn't guarantee
> the object is initialized before the reference is loaded
>
> c) r2 loads a reference to x, but uses synchronization to
> guarantee that the reference is not loaded until x is
> completely initialized.
>
>
> Now, I argue that even if r1 and r2 are run in the same thread,
> r2 should see the correctly initialized version of x.

Agreed.

> If you agree with feature 1, then I further argue for feature 2: if
> task r3 loads two difference references to x, the first incorrectly
> synchronized and the second correctly synchronized, then loads
> through the second reference should be valid, even if loads through
> the first reference are not.

Agreed. Though in practice I would expect the acquisition of the valid
reference to "fix" the invalid one.

David Holmes

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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