--- old/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java Thu Jan 10 16:20:26 2013 +++ new/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java Thu Jan 10 16:20:25 2013 @@ -111,7 +111,7 @@ * * @param expect the expected value * @param update the new value - * @return true if successful. + * @return true if successful */ public boolean weakCompareAndSet(boolean expect, boolean update) { int e = expect ? 1 : 0; @@ -146,16 +146,16 @@ * @return the previous value */ public final boolean getAndSet(boolean newValue) { - for (;;) { - boolean current = get(); - if (compareAndSet(current, newValue)) - return current; - } + boolean prev; + do { + prev = get(); + } while (!compareAndSet(prev, newValue)); + return prev; } /** * Returns the String representation of the current value. - * @return the String representation of the current value. + * @return the String representation of the current value */ public String toString() { return Boolean.toString(get());