125 /** |
125 /** |
126 * Possibly atomically sets the value to {@code newValue} |
126 * Possibly atomically sets the value to {@code newValue} |
127 * if the current value {@code == expectedValue}, |
127 * if the current value {@code == expectedValue}, |
128 * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
128 * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
129 * |
129 * |
|
130 * @deprecated This method has plain memory effects but the method |
|
131 * name implies volatile memory effects (see methods such as |
|
132 * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid |
|
133 * confusion over plain or volatile memory effects it is recommended that |
|
134 * the method {@link #weakCompareAndSetPlain} be used instead. |
|
135 * |
130 * @param expectedValue the expected value |
136 * @param expectedValue the expected value |
131 * @param newValue the new value |
137 * @param newValue the new value |
132 * @return {@code true} if successful |
138 * @return {@code true} if successful |
133 */ |
139 * @see #weakCompareAndSetPlain |
|
140 */ |
|
141 @Deprecated(since="9") |
134 public final boolean weakCompareAndSet(V expectedValue, V newValue) { |
142 public final boolean weakCompareAndSet(V expectedValue, V newValue) { |
|
143 return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue); |
|
144 } |
|
145 |
|
146 /** |
|
147 * Possibly atomically sets the value to {@code newValue} |
|
148 * if the current value {@code == expectedValue}, |
|
149 * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
|
150 * |
|
151 * @param expectedValue the expected value |
|
152 * @param newValue the new value |
|
153 * @return {@code true} if successful |
|
154 * @since 9 |
|
155 */ |
|
156 public final boolean weakCompareAndSetPlain(V expectedValue, V newValue) { |
135 return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue); |
157 return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue); |
136 } |
158 } |
137 |
159 |
138 /** |
160 /** |
139 * Atomically sets the value to {@code newValue} and returns the old value, |
161 * Atomically sets the value to {@code newValue} and returns the old value, |