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 value is set in program order, but with no assurance of memory ordering effects with respect to other threads.
public final void setOpaque(int i, E newValue)
Parameters: This method accepts:
- i which is an index of AtomicReferenceArray to perform the operation,
- newValue which is the new value to set.
Return value: This method returns nothing.
Below programs illustrate the setOpaque() method:
References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReferenceArray.html#setOpaque(int, E)
My Personal Notes arrow_drop_up
Please Login to comment...