CAS
该类用于对比当前值和期望值是否相同,相同就把当前值更新为更新值public final boolean compareAndSet(int expect, int update) { return unsafe.compareAndSwapInt(this, valueOffset, expect, update);}this:当前对象。valueOffset:内存地址偏移量expect:期望值update:更新值Unsafe类是什么?是CAS的核心类,由于Java方法无法
原创
2020-07-01 16:24:14 ·
157 阅读 ·
0 评论