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