is new.
java.lang.Objectjava.lang.Number
java.util.concurrent.atomic.AtomicInteger
public class AtomicInteger
An int value that may be updated atomically. See the java.util.concurrent.atomic package specification for description of the properties of atomic variables. An AtomicInteger is used in applications such as atomically incremented counters, and cannot be used as a replacement for an Integer . However, this class does extend Number to allow uniform access by tools and utilities that deal with numerically-based classes.
| Constructor Summary | |
|---|---|
AtomicInteger
()
Creates
|
|
AtomicInteger
(int initialValue)
Creates
|
|
| Method Summary | |
|---|---|
| int |
addAndGet
(int delta) Atomically
adds
the
current value. |
| boolean |
compareAndSet
(int expect, int update) Atomically
sets
|
| int |
decrementAndGet
() Atomically
decrements
|
| double |
doubleValue
() Returns the value of the specified number as a double. |
| float |
floatValue
() Returns the value of the specified number as a float. |
| int |
get
()
Gets
|
| int |
getAndAdd
(int delta) Atomically
adds
the
current value. |
| int |
getAndDecrement
() Atomically
decrements
|
| int |
getAndIncrement
() Atomically
increments
|
| int |
getAndSet
(int newValue)
Atomically sets
given
returns
|
| int |
incrementAndGet
() Atomically
increments
|
| int |
intValue
() Returns the value of the specified number as an int. |
void
|
lazySet
(int newValue)
Eventually sets to the given value.
|
| long |
longValue
() Returns the value of the specified number as a long. |
| void |
set
(int newValue)
Sets
|
| String |
toString
() Returns the String representation of the current value. |
| boolean |
weakCompareAndSet
(int expect, int update) Atomically
sets
|
| Methods inherited from class java.lang. Number |
|---|
| byteValue , shortValue |
| Methods inherited from class java.lang. Object |
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait |
| Constructor Detail |
|---|
public AtomicInteger(int initialValue)
Creates
public AtomicInteger()
Creates
| Method Detail |
|---|
public final int get()
Gets
public final void set(int newValue)
Sets
lazySet
public final void
lazySet
(int newValue)
Eventually sets to the given value.
Parameters:
newValue - the new value
Since:
1.6
public final int getAndSet(int newValue)
Atomically sets
given
returns
public final boolean compareAndSet(int expect,
int update)
sets
public final boolean weakCompareAndSet(int expect,
int update)
sets
public final int getAndIncrement()
increments
public final int getAndDecrement()
decrements
public final int getAndAdd(int delta)
adds
the
current value.
public final int incrementAndGet()
increments
public final int decrementAndGet()
decrements
public final int addAndGet(int delta)
adds
the
current value.
public String toString()
public int intValue()
public long longValue()
public float floatValue()
public double doubleValue()