Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

... writes that initialize the Helper object and the write to the helper field can be done or perceived out of order. As a result, a thread which invokes getHelper() could see a non-null reference to a helper object, but see the default values for fields of the helper object, rather than the values set in the constructor.

Even if the compiler does not reorder those writes, on a multiprocessor the processor or the memory system may reorder those writes, as perceived by a thread running on another processor.

See also CON26CON28-J. Do not publish partially initialized objects.

...