1 *java.util.concurrent.atomic.AtomicLong* *AtomicLong* A long value that may be u
3 public class AtomicLong
4 extends |java.lang.Number|
5 implements |java.io.Serializable|
7 |java.util.concurrent.atomic.AtomicLong_Description|
8 |java.util.concurrent.atomic.AtomicLong_Fields|
9 |java.util.concurrent.atomic.AtomicLong_Constructors|
10 |java.util.concurrent.atomic.AtomicLong_Methods|
12 ================================================================================
14 *java.util.concurrent.atomic.AtomicLong_Constructors*
15 |java.util.concurrent.atomic.AtomicLong()|Create a new AtomicLong with initial
16 |java.util.concurrent.atomic.AtomicLong(long)|Create a new AtomicLong with the
18 *java.util.concurrent.atomic.AtomicLong_Methods*
19 |java.util.concurrent.atomic.AtomicLong.addAndGet(long)|Atomically add the give
20 |java.util.concurrent.atomic.AtomicLong.compareAndSet(long,long)|Atomically set
21 |java.util.concurrent.atomic.AtomicLong.decrementAndGet()|Atomically decrement
22 |java.util.concurrent.atomic.AtomicLong.doubleValue()|
23 |java.util.concurrent.atomic.AtomicLong.floatValue()|
24 |java.util.concurrent.atomic.AtomicLong.get()|Get the current value.
25 |java.util.concurrent.atomic.AtomicLong.getAndAdd(long)|Atomically add the give
26 |java.util.concurrent.atomic.AtomicLong.getAndDecrement()|Atomically decrement
27 |java.util.concurrent.atomic.AtomicLong.getAndIncrement()|Atomically increment
28 |java.util.concurrent.atomic.AtomicLong.getAndSet(long)|Set to the give value a
29 |java.util.concurrent.atomic.AtomicLong.incrementAndGet()|Atomically increment
30 |java.util.concurrent.atomic.AtomicLong.intValue()|
31 |java.util.concurrent.atomic.AtomicLong.longValue()|
32 |java.util.concurrent.atomic.AtomicLong.set(long)|Set to the given value.
33 |java.util.concurrent.atomic.AtomicLong.toString()|Returns the String represent
34 |java.util.concurrent.atomic.AtomicLong.weakCompareAndSet(long,long)|Atomically
36 *java.util.concurrent.atomic.AtomicLong_Description*
38 A long value that may be updated atomically. See the
39 (|java.util.concurrent.atomic|) package specification for description of the
40 properties of atomic variables. An AtomicLong is used in applications such as
41 atomically incremented sequence numbers, and cannot be used as a replacement
42 for a (|java.lang.Long|) . However, this class does extend Number to allow
43 uniform access by tools and utilities that deal with numerically-based classes.
46 *java.util.concurrent.atomic.AtomicLong()*
50 Create a new AtomicLong with initial value 0.
53 *java.util.concurrent.atomic.AtomicLong(long)*
55 public AtomicLong(long initialValue)
57 Create a new AtomicLong with the given initial value.
59 initialValue - the initial value
61 *java.util.concurrent.atomic.AtomicLong.addAndGet(long)*
63 public final long addAndGet(long delta)
65 Atomically add the given value to current value.
67 delta - the value to add
69 Returns: the updated value
70 *java.util.concurrent.atomic.AtomicLong.compareAndSet(long,long)*
72 public final boolean compareAndSet(
76 Atomically set the value to the given updated value if the current value == the
79 expect - the expected value
80 update - the new value
82 Returns: true if successful. False return indicates that the actual value was not equal
83 to the expected value.
84 *java.util.concurrent.atomic.AtomicLong.decrementAndGet()*
86 public final long decrementAndGet()
88 Atomically decrement by one the current value.
91 Returns: the updated value
92 *java.util.concurrent.atomic.AtomicLong.doubleValue()*
94 public double doubleValue()
99 *java.util.concurrent.atomic.AtomicLong.floatValue()*
101 public float floatValue()
106 *java.util.concurrent.atomic.AtomicLong.get()*
108 public final long get()
110 Get the current value.
113 Returns: the current value
114 *java.util.concurrent.atomic.AtomicLong.getAndAdd(long)*
116 public final long getAndAdd(long delta)
118 Atomically add the given value to current value.
120 delta - the value to add
122 Returns: the previous value
123 *java.util.concurrent.atomic.AtomicLong.getAndDecrement()*
125 public final long getAndDecrement()
127 Atomically decrement by one the current value.
130 Returns: the previous value
131 *java.util.concurrent.atomic.AtomicLong.getAndIncrement()*
133 public final long getAndIncrement()
135 Atomically increment by one the current value.
138 Returns: the previous value
139 *java.util.concurrent.atomic.AtomicLong.getAndSet(long)*
141 public final long getAndSet(long newValue)
143 Set to the give value and return the old value.
145 newValue - the new value
147 Returns: the previous value
148 *java.util.concurrent.atomic.AtomicLong.incrementAndGet()*
150 public final long incrementAndGet()
152 Atomically increment by one the current value.
155 Returns: the updated value
156 *java.util.concurrent.atomic.AtomicLong.intValue()*
158 public int intValue()
163 *java.util.concurrent.atomic.AtomicLong.longValue()*
165 public long longValue()
170 *java.util.concurrent.atomic.AtomicLong.set(long)*
172 public final void set(long newValue)
174 Set to the given value.
176 newValue - the new value
178 *java.util.concurrent.atomic.AtomicLong.toString()*
180 public |java.lang.String| toString()
182 Returns the String representation of the current value.
185 Returns: the String representation of the current value.
186 *java.util.concurrent.atomic.AtomicLong.weakCompareAndSet(long,long)*
188 public final boolean weakCompareAndSet(
192 Atomically set the value to the given updated value if the current value == the
193 expected value. May fail spuriously.
195 expect - the expected value
196 update - the new value
198 Returns: true if successful.