Java API Tutorial - Java AtomicLong() Constructor








Syntax

AtomicLong() constructor from AtomicLong has the following syntax.

public AtomicLong()

Example

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

//www.jav a2s. 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());
  }
}

The code above generates the following result.