Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.atomic.AtomicInteger; public class AtomicIntegerCompareAndSetExample2 { public static void main(String[] args) { AtomicInteger number = new AtomicInteger(222); int expectedValue = 223; int newValue = 444; number.compareAndSet(expectedValue, newValue); System.out.println("the updated number:"+number); } }
Output