AtomicInteger的实现非常简单,所以我们可以很快就分析完它的实现原理,当然除了刚刚分析的这两个方法之外,还有其他的一些
比如它提供了compareAndSet,允许客户端基于AtomicInteger来实现乐观锁的操作
public final boolean compareAndSet(int expect,int update) {
return unsafe.compareAndSwapInt(this, valueOffset, expect, update);
}
AtomicInteger的实现非常简单,所以我们可以很快就分析完它的实现原理,当然除了刚刚分析的这两个方法之外,还有其他的一些
比如它提供了compareAndSet,允许客户端基于AtomicInteger来实现乐观锁的操作
public final boolean compareAndSet(int expect,int update) {
return unsafe.compareAndSwapInt(this, valueOffset, expect, update);
}