I have a very dumb question. If I use AtomicReferences compareAndSet this way
original.set(atomic.get());
long next = some new value
atomic.compareAndSet(original.get(), next);
....more code....
is more code still updated if the comparison fails (i.e. atomic has been updated by another thread). I'm trying to find an error in an assignment and this is the only thing I can think about and I've been trying for few hours.
P.S. Weirdly enough, if I use synchronize on this code it gives me the correct answer on my laptop, but not on my desktop