Java AtomicInteger.getAndAdd(int delta)
Syntax
AtomicInteger.getAndAdd(int delta) has the following syntax.
public final int getAndAdd(int delta)
Example
In the following code shows how to use AtomicInteger.getAndAdd(int delta) method.
import java.util.concurrent.atomic.AtomicInteger;
/*w w w.j a va2s .c o m*/
public class Main {
public static void main(String[] argv) throws Exception {
AtomicInteger atomicInteger = new AtomicInteger();
System.out.println(atomicInteger.getAndAdd(10));
System.out.println(atomicInteger.getAndAdd(10));
}
}
The code above generates the following result.