Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: final, volatile and synchronization protect against partial construction

...

Thread-safe classes (which may not be strictly immutable), such as Container in this noncompliant code example, must not declare fields as non- final and non-volatile or volatile, or synchronize all accesses of the field (see CON09-J. Do not assume that classes having only immutable members are thread-safe). NonIn the absence of synchronization, non-final, non-volatile fields may be observed by other threads before the sub-objects' initialization has concluded.

...