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