Tip, you don't actually have to read oldVal here. When the CAS fails, it will store the current value into oldVal before returning false. Saves you an extra read but this read has to move above the loop to execute the first read.