Open In App

AtomicReferenceArray setPlain() method in Java with Examples

Last Updated : 03 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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-final. Syntax:
public final void setPlain(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 setPlain() method: Program 1:
Output:
Program 2:
Output:
References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReferenceArray.html#setPlain(int, E)

Next Article

Similar Reads