Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed sequential consistency

Declaring shared variables as volatile ensures visibility and limits reordering of accesses. Volatile accesses do not guarantee the atomicity of composite operations such as incrementing a variable (CON01-J. Do not assume all primitive operators that composite operations on primitive data are atomic).

Declaring variables as volatile establishes a happens-before relationship such that a write to the volatile variable is always seen by a subsequent read. Statements that occur before the write to the volatile field also happen-before the read of the volatile field.

...

The use of the volatile keyword is inappropriate for composite operations on shared variables (CON01-J. Do not assume all primitive operators that composite operations on primitive data are atomic).

Noncompliant Code Example (visibility)

...