Versions Compared

Key

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

...

Thread-safe classes (which may not be strictly immutable), such as Container in this noncompliant code example, must not use nonfinal and nonvolatile fields to ensure that no thread sees any field references before the sub-objects' initialization has concluded. This noncompliant code example does not declare the map field as volatile or final. Consequently, a thread that invokes the get() method may observe the value of field map before initialization has concluded.

...