Compare-and-Swap

CAS is the cornerstone mechanism of lock-free algorithms. CAS atomically updates a memory location only when its current value still matches an expected value. AtomicInteger and other Atomic classes use CAS internally. When CAS fails becau…

1 sources - 4 claims

CAS is the cornerstone mechanism of lock-free algorithms. CAS atomically updates a memory location only when its current value still matches an expected value. AtomicInteger and other Atomic classes use CAS internally. When CAS fails because another thread changed the value first, the caller can retry.