[concurrency-interest] do constructors ever involve threading under the covers?

Aleksey Shipilev aleksey.shipilev at oracle.com
Wed Oct 3 11:48:25 EDT 2012

On 10/03/2012 07:22 PM, Vitaly Davidovich wrote:
> 1) assigning to final list *before* populating it doesn't conform to
> JMM.  It may work in practice if JIT doesn't rearrange things just
> because there's *any* final assignment in the ctor, but it could.  You'd
> have to instead populate a temp list and then assign it to the final
> field. 

This is true for volatile fields. But the semantics for final fields
seems to guarantee that the added element would be visible, because
(List.add) hb (freeze) in program order, and (freeze) hb (read reference
to new obj). Am I reading the spec incorrectly? Is it wrong to say
freeze action is the last action in program order of constructor?


More information about the Concurrency-interest mailing list