Is it safe to assume that the code before (AtomicInteger a).addAndGet(-1)
will be always executed before this call, i.e. JVM will not reorder the instructions around the addAndGet
call?
If yes, is it safe to assume that other threads checking the state of the same AtomicInteger
instance (e.g. if (a.compareAndSet(0, -1))
) will see everything the first thread has changed before the addAndGet
call?