Versions Compared

Key

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

Declaring a shared mutable variable volatile ensures the visibility of the latest updates on it , across other threads but does not guarantee the atomicity of composite operations. For example, the variable increment operation consisting of the sequence read-modify-write is not atomic even when the variable is declared volatile. In such cases, the java.util.concurrent utilities must be used to atomically manipulate the variable. If the utilities do not provide the required atomic methods, accesses to the variable must be explicitly synchronized.

...