Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.atomic.AtomicLong; public class AtomicLongCompareAndSetExample4 { public static void main (String [] args) { AtomicLong atomiclong = new AtomicLong(-10); long expectedValue = 10; long newValue = -20; atomiclong.compareAndSet(expectedValue, newValue); //Since Initialized value and expected value are not equal prints the Initialized value System.out.println(atomiclong); } }
Output