Java API Tutorial - Java AtomicLongArray .getAndDecrement (int i)








Syntax

AtomicLongArray.getAndDecrement(int i) has the following syntax.

public final long getAndDecrement(int i)

Example

In the following code shows how to use AtomicLongArray.getAndDecrement(int i) method.

/*w  w  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});
    System.out.println(atomicLongArray.getAndDecrement(2));
    System.out.println(atomicLongArray);
  }
}

The code above generates the following result.