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