106 /** |
106 /** |
107 * Possibly atomically sets the value to {@code newValue} |
107 * Possibly atomically sets the value to {@code newValue} |
108 * if the current value {@code == expectedValue}, |
108 * if the current value {@code == expectedValue}, |
109 * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
109 * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
110 * |
110 * |
111 * @param expectedValue the expected value |
111 * @deprecated This method has plain memory effects but the method |
112 * @param newValue the new value |
112 * name implies volatile memory effects (see methods such as |
113 * @return {@code true} if successful |
113 * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid |
114 */ |
114 * confusion over plain or volatile memory effects it is recommended that |
|
115 * the method {@link #weakCompareAndSetPlain} be used instead. |
|
116 * |
|
117 * @param expectedValue the expected value |
|
118 * @param newValue the new value |
|
119 * @return {@code true} if successful |
|
120 * @see #weakCompareAndSetPlain |
|
121 */ |
|
122 @Deprecated(since="9") |
115 public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) { |
123 public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) { |
116 return VALUE.weakCompareAndSetPlain(this, |
124 return VALUE.weakCompareAndSetPlain(this, |
117 (expectedValue ? 1 : 0), |
125 (expectedValue ? 1 : 0), |
118 (newValue ? 1 : 0)); |
126 (newValue ? 1 : 0)); |
119 } |
127 } |
120 |
128 |
121 /** |
129 /** |
|
130 * Possibly atomically sets the value to {@code newValue} |
|
131 * if the current value {@code == expectedValue}, |
|
132 * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
|
133 * |
|
134 * @param expectedValue the expected value |
|
135 * @param newValue the new value |
|
136 * @return {@code true} if successful |
|
137 * @since 9 |
|
138 */ |
|
139 public boolean weakCompareAndSetPlain(boolean expectedValue, boolean newValue) { |
|
140 return VALUE.weakCompareAndSetPlain(this, |
|
141 (expectedValue ? 1 : 0), |
|
142 (newValue ? 1 : 0)); |
|
143 } |
|
144 |
|
145 /** |
122 * Sets the value to {@code newValue}, |
146 * Sets the value to {@code newValue}, |
123 * with memory effects as specified by {@link VarHandle#setVolatile}. |
147 * with memory effects as specified by {@link VarHandle#setVolatile}. |
124 * |
148 * |
125 * @param newValue the new value |
149 * @param newValue the new value |
126 */ |
150 */ |