atomicCompareAndSet conditionally changes shared state: it writes a new value only when the current state still equals the supplied old value, returning true on success and false otherwise. section 8.2
Updating a counter without a mutex
A swap operation reads a snapshot, computes the next value, and calls atomicCompareAndSet. If another thread changed the state meanwhile, the comparison fails and swap retries with a fresh snapshot. A counter can therefore apply x + 1 without wrapping the update in an explicit lock. section 8.2
