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