谈谈aqs
保证多线程环境下的原子性
compareAndSwapInt
protected final boolean compareAndSetState(int expect, int update) {
return unsafe.compareAndSwapInt(this, stateOffset, expect, update);
}
该方法是一个native方法。如果安装了openJDK8,可以在hotspot/src/share/vm/prims/unsafe.cpp找
转载
2021-03-28 17:05:05 ·
108 阅读 ·
0 评论