Java AtomicLong.getAndDecrement()

Syntax

AtomicLong.getAndDecrement() has the following syntax.

public final long getAndDecrement()

Example

In the following code shows how to use AtomicLong.getAndDecrement() method.


import java.util.concurrent.atomic.AtomicLong;
/*from  w w w .  j a v  a  2 s  .c o  m*/
public class Main {
  public static void main(String[] argv) {
    AtomicLong nextId = new AtomicLong();

    System.out.println(nextId.getAndDecrement());
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.util.concurrent.atomic »




AtomicBoolean
AtomicInteger
AtomicIntegerArray
AtomicLong
AtomicLongArray