>
> If I'm not mistaken, JSR-133 only affects final fields so we still have
> the same problem for non-final fields.
> i.e any non-final fields in Messages might still be uninitialized even if
> the *reference* is visible to other threads (messages != null)
>
>

Actually, JSR-133 guarantees that final fields are initialised before
reference to the object is visible to other threads even not using
volatile. Change in 'volatile' was separate:


"* The semantics of volatile variables have been strengthened to have
acquire and release semantics. In the original specification, accesses to
volatile and non-volatile variables could be
freely ordered.

*  The semantics of final fields have been strengthened to allow for
thread-safe immutatability
without explicit synchronization. This may require steps such as
store-store barriers at the
end of constructors in which final fields are set."[1]


[1] http://www.cs.umd.edu/~pugh/java/memoryModel/jsr133.pdf



Cezary

Reply via email to