CAS底层原理?
unsafe valueoffset(内存偏移地址)
Unsafe是CAS的核心类
atomicInteger.getAndIncrement();
底层源码:::::
public final int getAndIncrement() {
return unsafe.getAndAddInt(this, valueOffset, 1);
}
public final int getAndAddInt(Object var1, long var2, int var4) {
int var5;
do {
var5 = this.getIntVolatile(var1, var2);
} while(!this.compareAndSwapInt(var1, var2, var5, var5 + var4));