Example usage for java.util.concurrent.atomic AtomicIntegerArray incrementAndGet

List of usage examples for java.util.concurrent.atomic AtomicIntegerArray incrementAndGet

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicIntegerArray incrementAndGet.

Prototype

public final int incrementAndGet(int i) 

Source Link

Document

Atomically increments the value of the element at index i , with memory effects as specified by VarHandle#getAndAdd .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 0, 1, 2, 3 });

    atomicIntegerArray.incrementAndGet(0);

    System.out.println(atomicIntegerArray);
}

From source file:com.netflix.iep.http.RxHttpTest.java

@Test
public void absoluteRedirect() throws Exception {
    int code = 200;
    statusCode.set(code);//from   ww w .j  a  v a  2s .  co m
    redirects.set(2);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.incrementAndGet(code);
    expected.addAndGet(302, 3);

    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> throwable = new AtomicReference<>();
    rxHttp.get(uri("/absoluteRedirect")).subscribe(Actions.empty(), new Action1<Throwable>() {
        @Override
        public void call(Throwable t) {
            throwable.set(t);
            latch.countDown();
        }
    }, new Action0() {
        @Override
        public void call() {
            latch.countDown();
        }
    });

    latch.await();
    Assert.assertNull(throwable.get());
    assertEquals(expected, statusCounts);
}