java7 java8 compareAndSwapLong

我们可以窥见 JDK 8 在 x86 平台上对 compareAndSwapLong 方法做了一些操作,使用了 xadd 汇编指令代替 CAS 操作。

xadd 指令是 fetch and add。

cmpxchg 指令是 compare and swap。

xadd 指令的性能是优于 cmpxchg 指令的。

LongAdder ; 最终一致性, 高并发获取值 比 AtomLong好点, 如果不需要当时就返回正确值时

评论