Java AtomicInteger.lazySet(int newValue)

Syntax

AtomicInteger.lazySet(int newValue) has the following syntax.

public final void lazySet(int newValue)

Example

In the following code shows how to use AtomicInteger.lazySet(int newValue) method.


import java.util.concurrent.atomic.AtomicInteger;
//from   w  w  w. j a  va2s  .  co m
public class Main {
  public static void main(String[] argv) throws Exception {
    AtomicInteger atomicInteger = new AtomicInteger();
    
    atomicInteger.lazySet(2);
    
    System.out.println(atomicInteger);
  }
}

The code above generates the following result.





















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




AtomicBoolean
AtomicInteger
AtomicIntegerArray
AtomicLong
AtomicLongArray