java-并发-源码-AtomicInteger
包含一个unsafe,value用于保存值
    private static final Unsafe unsafe = Unsafe.getUnsafe();
    private static final long valueOffset;
	private volatile int value;
lazySet
getAndSet
compareAndSet
weakCompareAndSet
getAndIncrement
getAndDecrement
getAndAdd
incrementAndGet
decrementAndGet
addAndGet
getAndUpdate
updateAndGet
getAndAccumulate
accumulateAndGet
intValue/longValue/floatValue/doubleValue
例子:accumulateAndGet
    AtomicInteger atomicInteger = new AtomicInteger(10);
    class Opa implements IntBinaryOperator {
        @Override
        public int applyAsInt(int left, int right) {
            return 0;
        }
    }
    atomicInteger.accumulateAndGet(10, new IntBinaryOperator() {
        @Override
        public int applyAsInt(int left, int right) {
            return left*right;
        }
    });
 
                    
                
 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号