Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot (vkp)

...

This does not prevent either thread from observing an inconsistent value of counter because the increment operation on volatile fields is not atomic in the absence of proper synchronization (see CON02 VNA02-J. Ensure that compound operations on shared variables are atomic).

Noncompliant Code Example (Method Synchronization for Static Data)

...