May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to {@code compareAndSet}. @param expect the expected value @param update the new value @return {@code true} if successful
4445464748495051525354
} @Test public void weakCompareAndSet() throws Exception { AtomicBoolean value = new AtomicBoolean(); assert value.weakCompareAndSet(false, true); value.set(true); assert !value.weakCompareAndSet(false, false); }
4748495051525354555657
public void weakCompareAndSet() throws Exception { AtomicBoolean value = new AtomicBoolean(); assert value.weakCompareAndSet(false, true); value.set(true); assert !value.weakCompareAndSet(false, false); } @Test public void lazySet() throws Exception { AtomicBoolean value = new AtomicBoolean();