public final boolean compareAndExchange (boolean expectedValue, boolean newValue)

Atomically sets the value to newValue if the current value, referred to as the witness value, == expectedValue, with memory effects as specified by VarHandle.compareAndExchange.

Parameters:
expectedValue    the expected value
newValue    the new value

Returns:  the witness value, which will be the same as the expected value if successful

Since:  9