...
Note that if Foo
was mutable, the Helper
field would need to be declared volatile
as shown in CON00-J. Declare status flags as volatileEnsure visibility of atomically modifiable shared variables. Also, the method getHelper()
is an instance method and the accessibility of the helper
field is private
. This allows safe publication of the Helper
object, in that, a thread cannot observe a partially initialized Foo
object (CON26-J. Do not publish partially-constructed objects).
...