37 * A small toolkit of classes that support lock-free thread-safe
38 * programming on single variables. Instances of Atomic classes
39 * maintain values that are accessed and updated using methods
40 * otherwise available for fields using associated atomic {@link
41 * java.lang.invoke.VarHandle} operations.
42 *
43 * <p>Instances of classes
44 * {@link java.util.concurrent.atomic.AtomicBoolean},
45 * {@link java.util.concurrent.atomic.AtomicInteger},
46 * {@link java.util.concurrent.atomic.AtomicLong}, and
47 * {@link java.util.concurrent.atomic.AtomicReference}
48 * each provide access and updates to a single variable of the
49 * corresponding type. Each class also provides appropriate utility
50 * methods for that type. For example, classes {@code AtomicLong} and
51 * {@code AtomicInteger} provide atomic increment methods. One
52 * application is to generate sequence numbers, as in:
53 *
54 * <pre> {@code
55 * class Sequencer {
56 * private final AtomicLong sequenceNumber
57 * = new AtomicLong(0);
58 * public long next() {
59 * return sequenceNumber.getAndIncrement();
60 * }
61 * }}</pre>
62 *
63 * <p>Arbitrary transformations of the contained value are provided both
64 * by low-level read-modify-write operations such as {@code compareAndSet}
65 * and by higher-level methods such as {@code getAndUpdate}.
66 *
67 * <p>These classes are not general purpose replacements for {@code
68 * java.lang.Integer} and related classes. They do <em>not</em>
69 * define methods such as {@code equals}, {@code hashCode} and {@code
70 * compareTo}. Because atomic variables are expected to be mutated,
71 * they are poor choices for hash table keys.
72 *
73 * <p>The
74 * {@link java.util.concurrent.atomic.AtomicIntegerArray},
75 * {@link java.util.concurrent.atomic.AtomicLongArray}, and
76 * {@link java.util.concurrent.atomic.AtomicReferenceArray} classes
77 * further extend atomic operation support to arrays of these types.
|
37 * A small toolkit of classes that support lock-free thread-safe
38 * programming on single variables. Instances of Atomic classes
39 * maintain values that are accessed and updated using methods
40 * otherwise available for fields using associated atomic {@link
41 * java.lang.invoke.VarHandle} operations.
42 *
43 * <p>Instances of classes
44 * {@link java.util.concurrent.atomic.AtomicBoolean},
45 * {@link java.util.concurrent.atomic.AtomicInteger},
46 * {@link java.util.concurrent.atomic.AtomicLong}, and
47 * {@link java.util.concurrent.atomic.AtomicReference}
48 * each provide access and updates to a single variable of the
49 * corresponding type. Each class also provides appropriate utility
50 * methods for that type. For example, classes {@code AtomicLong} and
51 * {@code AtomicInteger} provide atomic increment methods. One
52 * application is to generate sequence numbers, as in:
53 *
54 * <pre> {@code
55 * class Sequencer {
56 * private final AtomicLong sequenceNumber
57 * = new AtomicLong(17);
58 * public long next() {
59 * return sequenceNumber.getAndIncrement();
60 * }
61 * }}</pre>
62 *
63 * <p>Arbitrary transformations of the contained value are provided both
64 * by low-level read-modify-write operations such as {@code compareAndSet}
65 * and by higher-level methods such as {@code getAndUpdate}.
66 *
67 * <p>These classes are not general purpose replacements for {@code
68 * java.lang.Integer} and related classes. They do <em>not</em>
69 * define methods such as {@code equals}, {@code hashCode} and {@code
70 * compareTo}. Because atomic variables are expected to be mutated,
71 * they are poor choices for hash table keys.
72 *
73 * <p>The
74 * {@link java.util.concurrent.atomic.AtomicIntegerArray},
75 * {@link java.util.concurrent.atomic.AtomicLongArray}, and
76 * {@link java.util.concurrent.atomic.AtomicReferenceArray} classes
77 * further extend atomic operation support to arrays of these types.
|