Java AtomicLong.lazySet(long newValue)

Syntax

AtomicLong.lazySet(long newValue) has the following syntax.

public final void lazySet(long newValue)

Example

In the following code shows how to use AtomicLong.lazySet(long newValue) method.


/*  ww w  . ja  va 2 s.  com*/
import java.util.concurrent.atomic.AtomicLong;

public class Main {
  public static void main(String[] argv) {
    AtomicLong nextId = new AtomicLong();
    
    nextId.lazySet(12312L);

    System.out.println(nextId.getAndIncrement());
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.util.concurrent.atomic »




AtomicBoolean
AtomicInteger
AtomicIntegerArray
AtomicLong
AtomicLongArray