Java API Tutorial - 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  ww . j  a v a 2  s . 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.