AtomicReference setOpaque() method in Java with Examples Last Updated : 27 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 threads. Syntax: public final void setOpaque(V newValue) Parameters: This method accepts newValue which is the new value to set. Return value: This method returns nothing. Below programs illustrate the setOpaque() method: Program 1: Java // Java program to demonstrate // AtomicReference.setOpaque() method import java.util.concurrent.atomic.AtomicReference; public class GFG { public static void main(String[] args) { // create an atomic reference object. AtomicReference<Float> ref = new AtomicReference<Float>(); // set some value using setOpaque method ref.setOpaque((float)9999.79); // print value System.out.println("value = " + ref.get()); } } Output: Program 2: Java // Java program to demonstrate // AtomicReference.setOpaque() 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 setOpaque() ref.setOpaque("CP Algos"); // print value System.out.println("Algo = " + ref.get()); } } Output: References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReference.html#setOpaque(V) Comment More infoAdvertise with us Next Article AtomicReference set() 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 setOpaque() method in Java with Examples The setOpaque() 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.setOpaque(java.lang.Object...). In this way 2 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 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 setRelease() method in Java with Examples 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 s 1 min read AtomicReferenceArray set() method in Java with Examples The set() 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 semantics of reading as if the variable was declared volatile type of variable. Syn 2 min read AtomicReferenceArray setPlain() method in Java with Examples The setPlain() 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 semantics of setting as if the variable was declared non-volatile and non-fina 2 min read Like