...
However, synchronization is a more secure alternative in situations where the volatile
keyword or an java.util.concurrent.atomic.Atomic*
field is inappropriate, such as if a variable's new value depends on its old value. Refer to CON01-J. Ensure that composite compound operations on shared variables are atomic for more information.
...