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