"The initial load (i.e., the very first encounter by a thread) of a final field cannot be reordered with the initial load of the reference to the object containing the final field. This comes into play in: x = sharedRef; ... ; i = x.finalField; A compiler would never reorder these since they are dependent, but there can be consequences of this rule on some processors."
Note that there are no constraints placed on sharedRef. It does not need to be volatile, for instance.
This link also has more useful info and examples: https://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.ht...
Right - I think the processor can still reorder. I've never been sure why the compiler is not allowed to reorder in this case, since this doesn't help you if the processor will do it anyway.
In the example you're mentioning if "Thing" is built with finals or if it is synchronized, then it can't have problems.
And given that "Thing" in this sample is meant to be accessed by multiple threads, then if that access isn't synchronized, then the double-checked pattern is not going to be your only problem ;-)
Basically when assigning a new object to a reference, the only way to know for sure that its internals are initialized before the assignment is to either work with finals or to synchronize that internal state.
It only works with the updated semantics of volatile (Java 5+), otherwise you're right.
This is why the common pattern of double-checked locking is bad. This is:
Don't do that. You could get hold of a partially-constructed Thing.