...
Semantics of volatile
do not guarantee the atomicity of compound operations that involve read-modify-write sequences such as incrementing a value. See CON02 VNA02-J. Ensure that compound operations on shared variables are atomic for more information.
Exceptions
CON05-EX1: If all reads and writes of 64-bit long
and double
values occur within a synchronized region, the atomicity of the read/write is guaranteed. This requires that no unsynchronized methods in the class expose the value and that the value is inaccessible (directly or indirectly) from other code. (For more information, see CON02 VNA02-J. Ensure that compound operations on shared variables are atomic.)
CON05-EX2: Systems that guarantee that 64-bit long
and double
values are read and written as atomic operations may safely ignore this guideline.
...