Versions Compared

Key

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

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. Design APIs that ensure atomicity of composite operations and visibility of results).

A write to a volatile field happens-before every subsequent read of that field. Statements that occur before the write to the volatile field also happen-before the read of the volatile field.

...