AtomicReference setRelease() method in Java with Examples Last Updated : 27 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The setRelease() 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...). This method has memory ordering effects compatible with memory_order_release ordering. Syntax: public final void setRelease(V newValue) Parameters: This method accepts newValue which is the new value to set. Return value: This method returns nothing. Below programs illustrate the setRelease() method: Program 1: Java // Java program to demonstrate // AtomicReference.setRelease() method import java.util.concurrent.atomic.AtomicReference; public class GFG { public static void main(String[] args) { // create an atomic reference object. AtomicReference<Long> ref = new AtomicReference<Long>(); // set some value using setRelease method ref.setRelease(123457876L); // print value System.out.println("value = " + ref.get()); } } Output: Program 2: Java // Java program to demonstrate // AtomicReference.setRelease() 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 setRelease() ref.setRelease("String Builder"); // print value System.out.println("Class = " + ref.get()); } } Output: References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReference.html#setRelease(V) Comment More infoAdvertise with us Next Article AtomicReference setPlain() 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 setRelease() method in Java with Examples The setRelease() 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...). This meth 2 min read AtomicReference setPlain() method in Java with Examples The setPlain() method of a AtomicReference class is used to set the value of this AtomicReference object with memory semantics of setting as if the variable was declared non-volatile and non-final. Syntax: public final void setPlain(V newValue) Parameters: This method accepts newValue which is the n 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 setOpaque() method in Java with Examples The setOpaque() method of a AtomicReference class is used to set the value of this AtomicReference object with memory effects as specified by VarHandle.setOpaque(java.lang.Object...). In this way value is set in program order, but with no assurance of memory ordering effects with respect to other th 1 min read AtomicReference weakCompareAndSetRelease() method in Java with Examples The weakCompareAndSetRelease() method of a AtomicReference class is used to atomically sets the value to newValue for AtomicReference if the current value is equal to expectedValue passed as parameter. This method updates the value and ensures that prior loads and stores are not reordered after this 2 min read AtomicReference toString() method in Java with Examples The toString() method of a AtomicReference class is used to return the String representation of the current value of AtomicReference object. Syntax: public String toString() Parameters: This method accepts nothing. Return value: This method returns the String representation of the current value. Bel 1 min read Like