6 |
|
|
7 |
|
package jsr166e; |
8 |
|
import java.util.concurrent.atomic.AtomicLong; |
9 |
– |
import java.io.IOException; |
9 |
|
import java.io.Serializable; |
11 |
– |
import java.io.ObjectInputStream; |
12 |
– |
import java.io.ObjectOutputStream; |
10 |
|
|
11 |
|
/** |
12 |
|
* One or more variables that together maintain an initially zero |
16 |
|
* #longValue}) returns the current total combined across the |
17 |
|
* variables maintaining the sum. |
18 |
|
* |
19 |
< |
* <p> This class is usually preferable to {@link AtomicLong} when |
19 |
> |
* <p>This class is usually preferable to {@link AtomicLong} when |
20 |
|
* multiple threads update a common sum that is used for purposes such |
21 |
|
* as collecting statistics, not for fine-grained synchronization |
22 |
|
* control. Under low update contention, the two classes have similar |
25 |
|
* consumption. |
26 |
|
* |
27 |
|
* <p>This class extends {@link Number}, but does <em>not</em> define |
28 |
< |
* methods such as {@code hashCode} and {@code compareTo} because |
29 |
< |
* instances are expected to be mutated, and so are not useful as |
30 |
< |
* collection keys. |
28 |
> |
* methods such as {@code equals}, {@code hashCode} and {@code |
29 |
> |
* compareTo} because instances are expected to be mutated, and so are |
30 |
> |
* not useful as collection keys. |
31 |
|
* |
32 |
|
* <p><em>jsr166e note: This class is targeted to be placed in |
33 |
|
* java.util.concurrent.atomic.</em> |
82 |
|
|
83 |
|
/** |
84 |
|
* Returns the current sum. The returned value is <em>NOT</em> an |
85 |
< |
* atomic snapshot: Invocation in the absence of concurrent |
85 |
> |
* atomic snapshot; invocation in the absence of concurrent |
86 |
|
* updates returns an accurate result, but concurrent updates that |
87 |
|
* occur while the sum is being calculated might not be |
88 |
|
* incorporated. |
188 |
|
s.writeLong(sum()); |
189 |
|
} |
190 |
|
|
191 |
< |
private void readObject(ObjectInputStream s) |
192 |
< |
throws IOException, ClassNotFoundException { |
191 |
> |
private void readObject(java.io.ObjectInputStream s) |
192 |
> |
throws java.io.IOException, ClassNotFoundException { |
193 |
|
s.defaultReadObject(); |
194 |
|
busy = 0; |
195 |
|
cells = null; |