AtomicLong.addAndGet(long delta) has the following syntax.
public final long addAndGet(long delta)
In the following code shows how to use AtomicLong.addAndGet(long delta) method.
import java.util.concurrent.atomic.AtomicLong; //from ww w. j ava2s .c om public class Main { public static void main(String[] argv) { AtomicLong nextId = new AtomicLong(); System.out.println(nextId.getAndIncrement()); System.out.println(nextId.addAndGet(100L)); } }
The code above generates the following result.