How does Java's atomic variables like AtomicInteger work internally to achieve mutual exclusion/atomicity?
Is there any locking involved at machine instruction level which yields better performance?
Or an atomic machine level instruction itself does this compared to the regular set of machine instructions where the value is copied from main memory to register/cache and operation performed on this register and then stored back in main memory.