How does “Compare And Set” in AtomicInteger works
The atomic objects make use of Compare and Swap mechanism to make them atomic – i.e. it is possible to guarantee that the value was as specified and is now at the new value. The code you posted continually tries to set the current value to one more than it was before. Remember that another … Read more