private static AtomicReference<Integer> atomicReference = new AtomicReference<>(0);
private static AtomicReference<Integer> atomicReference1 = new AtomicReference<>(100);
atomicReference.compareAndSet(0, 2);
atomicReference.compareAndSet(0, 3);
atomicReference.compareAndSet(2, 4);
atomicReference.compareAndSet(3, 5);
System.out.println(atomicReference.get());
atomicReference1.compareAndSet(100, 200);
atomicReference1.compareAndSet(100, 300);
atomicReference1.compareAndSet(200, 400);
atomicReference1.compareAndSet(300, 500);
System.out.println(atomicReference1.get());
然而运行出来的结果
atomicReference为4
atomicReference1为200.
问题.atomicReference1为什么是200 而不是400