import java.util.concurrent.atomic.AtomicBoolean; public class AtomicBooleanExample { public static void main(String[] args) { AtomicBoolean flag = new AtomicBoolean(true); // Perform an atomic update to set the value to false boolean oldValue = flag.getAndSet(false); System.out.println("Old value: " + oldValue); System.out.println("New value: " + flag.get()); } }The code creates a new AtomicBoolean with an initial value of true. It then performs an atomic update to set the value to false, and prints out the old and new values. The AtomicBoolean class is part of the java.util.concurrent.atomic package in the Java standard library.