import java.util.concurrent.atomic.AtomicBoolean; public class AtomicBooleanExample { public static void main(String[] args) { AtomicBoolean bool = new AtomicBoolean(true); boolean expectedValue = true; boolean newValue = false; boolean wasUpdated = bool.compareAndSet(expectedValue, newValue); if (wasUpdated) { System.out.println("Boolean was updated successfully!"); } else { System.out.println("Boolean was not updated."); } } }In this example, we create a new AtomicBoolean with an initial value of true. We then use compareAndSet to attempt to update the boolean value from true to false. Since the expected value is true, the update should be successful, and we print out a message indicating that the update was successful.