Create id from java .util .concurrent .AtomicLong in Java

Description

The following code shows how to create id from java.util.concurrent.AtomicLong.

Example


/*w ww.  j a va  2  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());
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Thread »




Data Structure
Semaphore
Thread