--- jsr166/src/jsr166e/LongAdder.java 2011/08/02 18:04:12 1.5 +++ jsr166/src/jsr166e/LongAdder.java 2012/11/18 03:07:22 1.9 @@ -33,8 +33,9 @@ import java.io.ObjectOutputStream; * collection keys. * *

jsr166e note: This class is targeted to be placed in - * java.util.concurrent.atomic + * java.util.concurrent.atomic. * + * @since 1.8 * @author Doug Lea */ public class LongAdder extends Striped64 implements Serializable { @@ -92,8 +93,8 @@ public class LongAdder extends Striped64 * @return the sum */ public long sum() { - Cell[] as = cells; long sum = base; + Cell[] as = cells; if (as != null) { int n = as.length; for (int i = 0; i < n; ++i) { @@ -127,17 +128,16 @@ public class LongAdder extends Striped64 * @return the sum */ public long sumThenReset() { - Cell[] as = cells; long sum = base; + Cell[] as = cells; base = 0L; if (as != null) { int n = as.length; for (int i = 0; i < n; ++i) { Cell a = as[i]; if (a != null) { - long v = a.value; + sum += a.value; a.value = 0L; - sum += v; } } } @@ -146,7 +146,7 @@ public class LongAdder extends Striped64 /** * Returns the String representation of the {@link #sum}. - * @return the String representation of the {@link #sum}. + * @return the String representation of the {@link #sum} */ public String toString() { return Long.toString(sum());