AtomicBoolean.weakCompareAndSet(boolean expect, boolean update) has the following syntax.
public boolean weakCompareAndSet(boolean expect, boolean update)
In the following code shows how to use AtomicBoolean.weakCompareAndSet(boolean expect, boolean update) method.
//from w w w . j a v a 2s .c o m import java.util.concurrent.atomic.AtomicBoolean; public class Main { public static void main(String[] argv) throws Exception { AtomicBoolean atomicBoolean = new AtomicBoolean(); atomicBoolean.weakCompareAndSet(true,true); System.out.println(atomicBoolean); } }
The code above generates the following result.