[concurrency-interest] Reordering and Immutability
davidcholmes at aapt.net.au
Wed Feb 6 15:51:59 EST 2013
Sorry I have non-html based mailer so responding inline is not reasonable.
The implicit initialization of static fields to their default values will
always happen-before any thread can see those fields due to the class
initialization process. So the reference is either null or a proper
reference to an object that may or may not be itself properly initialized.
It can never be a random set of bits.
From: oleksandr otenko [mailto:oleksandr.otenko at oracle.com]
Sent: Thursday, 7 February 2013 3:47 AM
To: dholmes at ieee.org
Cc: David Holmes; Yann Le Tallec; concurrency-interest at cs.oswego.edu
Subject: Re: [concurrency-interest] Reordering and Immutability
On 03/02/2013 21:21, David Holmes wrote:
Yann Le Tallec writes:
(2) Same question with resource declared as "private static Resource
resource;" (without the "= null") and with the additional assumption
that Resource is immutable
- I am told that "Resource resource; can't race whereas Resource
resource = null; can", but I don't see why they are different from a
There is no difference. "Resource resource;" implicitly sets resource to
null during static initialization of the class.
Then it may also return a non-null value that is not even a valid
reference, and certainly doesn't necessarily reference a valid Resource
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest