AtomicLong是支持Long类型的原子执行器,AtomicLongFieldUpdater是long字段原子执行器,可以把某个类中的valitile long字段进行原子性操作。
这样做可以避免直接使用AtomicLong这样的类级别属性,直接使用long基本类型字段,然后在需要使用原子性加减的地方可以通过AtomicLongFieldUpdater包装成CASUpdater或则LockedUpdater进行原子性操作。
使用AtomicLongFieldUpdater需要注意原字段非原子性更新操作的影响。
注:
https://blog.csdn.net/liangruilz/article/details/103758965
https://stackoverflow.com/questions/59209313/why-do-atomiclong-and-atomiclongfieldupdater-implement-compareandset-differently
https://www.cnblogs.com/skywang12345/p/3514635.html