Example usage for java.util.concurrent.atomic AtomicLongArray compareAndSet

List of usage examples for java.util.concurrent.atomic AtomicLongArray compareAndSet

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicLongArray compareAndSet.

Prototype

public final boolean compareAndSet(int i, long expectedValue, long newValue) 

Source Link

Document

Atomically sets the element at index i to newValue if the element's current value == expectedValue , with memory effects as specified by VarHandle#compareAndSet .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    AtomicLongArray atomicLongArray = new AtomicLongArray(new long[] { 1L, 2L, 3L, 4L });
    System.out.println(atomicLongArray.compareAndSet(2, 10L, 20L));
    System.out.println(atomicLongArray);
}