Class AtomicBoolean


  • public class AtomicBoolean
    extends Object
    A boolean value that may be updated atomically.
    Author:
    Rein Raudjärv
    • Constructor Detail

      • AtomicBoolean

        public AtomicBoolean​(boolean initialValue)
        Creates a new AtomicBoolean with the given initial value.
        Parameters:
        initialValue - the initial value
    • Method Detail

      • get

        public boolean get()
        Returns the current value.
        Returns:
        the current value
      • set

        public void set​(boolean value)
        Unconditionally sets to the given value.
        Parameters:
        newValue - the new value
      • compareAndSet

        public boolean compareAndSet​(boolean expect,
                                     boolean update)
        Atomically set the value to the given updated value if the current value == the expected value.
        Parameters:
        expect - the expected value
        update - the new value
        Returns:
        true if successful. False return indicates that the actual value was not equal to the expected value.