AtomicReference lazySet() method in Java with Examples Last Updated : 27 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The lazySet() method of a AtomicReference class is used to set the value of this AtomicReference object with memory effects as specified by VarHandle.setRelease(java.lang.Object...) to ensures that prior loads and stores are not reordered after this access. Syntax: public final void lazySet(V newValue) Parameters: This method accepts newValue which is the new value to set. Return value: This method returns nothing. Below programs illustrate the lazySet() method: Program 1: Java // Java program to demonstrate // AtomicReference.lazySet() method import java.util.concurrent.atomic.AtomicReference; public class GFG { public static void main(String[] args) { // create an atomic reference object. AtomicReference<Integer> ref = new AtomicReference<Integer>(); // set some value using lazySet method ref.lazySet(67545678); // print value System.out.println("Integer value = " + ref.get()); } } Output: Integer value = 67545678 Program 2: Java // Java program to demonstrate // AtomicReference.lazySet() method import java.util.concurrent.atomic.AtomicReference; public class GFG { public static void main(String[] args) { // create an atomic reference object AtomicReference<String> ref = new AtomicReference<String>(); // set some value using lazySet() ref.lazySet("GFG(GeeksForGeeks)"); // print value System.out.println(ref.get()); } } Output: GFG(GeeksForGeeks) References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReference.html#lazySet(V) Comment More infoAdvertise with us Next Article AtomicBoolean lazySet() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Java-util-concurrent-atomic package Practice Tags : Java Similar Reads AtomicReferenceArray lazySet() method in Java with Examples The lazySet() method of a AtomicReferenceArray class is used to set the value of the element at index i to newValue. Both index i and newValue are passed as parameters to the method. This method set the value with memory effects as specified by VarHandle.setRelease(java.lang.Object...) to ensures th 2 min read AtomicInteger lazySet() method in Java with examples The java.util.concurrent.atomic.AtomicInteger.lazySet() is an inbuilt method in java that updates the previous value and sets it to a new value which is passed in the parameter. Syntax: public final void lazySet(int newVal) Parameters: The function accepts a single mandatory parameter newVal which i 1 min read AtomicLong lazySet() method in Java with examples The Java.util.concurrent.atomic.AtomicLong.lazySet() is an inbuilt method in java that updates the previous value and sets it to a new value which is passed in the parameter. Syntax: public final void lazySet(long newVal) Parameters: The function accepts a single mandatory parameter newVal which is 1 min read AtomicBoolean lazySet() method in Java with Examples The java.util.concurrent.atomic.AtomicBoolean.lazySet() is an inbuilt method in java that updates the previous value and sets it to a new value which is passed in the parameter. Syntax: public final void lazySet(boolean newVal) Parameters: The function accepts a single mandatory parameter newVal whi 1 min read AtomicReference set() method in Java with Examples The set() method of a AtomicReference class is used to set the value of this AtomicReference object with memory semantics of reading as if the variable was declared volatile type of variable. Syntax: public final void set(V newValue) Parameters: This method accepts newValue which is the new value to 1 min read AtomicReference get() method in Java with Examples The get() method of a AtomicReference class is used to return the value of this AtomicReference object with memory semantics of reading as if the variable was declared volatile type of variable. Syntax: public final V get() Parameters: This method accepts nothing. Return value: This method returns c 1 min read Like