diff -r 7fd4548e9733 -r 9c298252e385 jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java Mon Oct 10 15:46:14 2016 -0700 +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java Mon Oct 10 15:58:42 2016 -0700 @@ -148,15 +148,37 @@ * if the current value {@code == expectedValue}, * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * + * @deprecated This method has plain memory effects but the method + * name implies volatile memory effects (see methods such as + * {@link #compareAndExchange} and {@link #compareAndSet}). To avoid + * confusion over plain or volatile memory effects it is recommended that + * the method {@link #weakCompareAndSetPlain} be used instead. + * * @param expectedValue the expected value * @param newValue the new value * @return {@code true} if successful + * @see #weakCompareAndSetPlain */ + @Deprecated(since="9") public final boolean weakCompareAndSet(int expectedValue, int newValue) { return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue); } /** + * Possibly atomically sets the value to {@code newValue} + * if the current value {@code == expectedValue}, + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. + * + * @param expectedValue the expected value + * @param newValue the new value + * @return {@code true} if successful + * @since 9 + */ + public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) { + return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue); + } + + /** * Atomically increments the current value, * with memory effects as specified by {@link VarHandle#getAndAdd}. *