AtomicLongArray.weakCompareAndSet(int i, long expect, long update) has the following syntax.
public final boolean weakCompareAndSet(int i, long expect, long update)
In the following code shows how to use AtomicLongArray.weakCompareAndSet(int i, long expect, long update) method.
//ww w . ja v a 2 s.co m import java.util.concurrent.atomic.AtomicLongArray; public class Main { public static void main(String[] argv) throws Exception { AtomicLongArray atomicLongArray = new AtomicLongArray(new long[]{1L,2L,3L,4L}); atomicLongArray.weakCompareAndSet(2,10L,20L); System.out.println(atomicLongArray); } }
The code above generates the following result.