Java AtomicLong.incrementAndGet()
Syntax
AtomicLong.incrementAndGet() has the following syntax.
public final long incrementAndGet()
Example
In the following code shows how to use AtomicLong.incrementAndGet() method.
/*from ww w . j a v a2 s.c o m*/
import java.util.concurrent.atomic.AtomicLong;
public class Main {
public static void main(String[] argv) {
AtomicLong nextId = new AtomicLong();
System.out.println(nextId.getAndIncrement());
System.out.println(nextId.incrementAndGet());
}
}
The code above generates the following result.