|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.util.concurrent.atomic.AtomicIntegerArray
public class AtomicIntegerArray
可以用原子方式更新其元素的 int 数组。有关原子变量属性的描述,请参阅 java.util.concurrent.atomic 包规范。
| 构造方法摘要 | |
|---|---|
AtomicIntegerArray(int length)
创建给定长度的新 AtomicIntegerArray。 |
|
AtomicIntegerArray(int[] array)
创建与给定数组具有相同长度的新 AtomicIntegerArray,并从给定数组复制其所有元素。 |
|
| 方法摘要 | |
|---|---|
int |
addAndGet(int i,
int delta)
以原子方式将给定值与索引 i 的元素相加。 |
boolean |
compareAndSet(int i,
int expect,
int update)
如果当前值 == 预期值,则以原子方式将位置 i 的元素设置为给定的更新值。 |
int |
decrementAndGet(int i)
以原子方式将索引 i 的元素减 1。 |
int |
get(int i)
获取位置 i 的当前值。 |
int |
getAndAdd(int i,
int delta)
以原子方式将给定值与索引 i 的元素相加。 |
int |
getAndDecrement(int i)
以原子方式将索引 i 的元素减 1。 |
int |
getAndIncrement(int i)
以原子方式将索引 i 的元素加 1。 |
int |
getAndSet(int i,
int newValue)
将位置 i 的元素以原子方式设置为给定值,并返回旧值。 |
int |
incrementAndGet(int i)
以原子方式将索引 i 的元素加 1。 |
void |
lazySet(int i,
int newValue)
最后将位置 i 的元素设置为给定值。 |
int |
length()
返回该数组的长度。 |
void |
set(int i,
int newValue)
将位置 i 的元素设置为给定值。 |
String |
toString()
返回数组当前值的字符串表示形式。 |
boolean |
weakCompareAndSet(int i,
int expect,
int update)
如果当前值 == 预期值,则以原子方式将位置 i 的元素设置为给定的更新值。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
public AtomicIntegerArray(int length)
length - 该数组的长度public AtomicIntegerArray(int[] array)
array - 从中复制元素的数组
NullPointerException - 如果数组为 null| 方法详细信息 |
|---|
public final int length()
public final int get(int i)
i 的当前值。
i - 索引
public final void set(int i,
int newValue)
i 的元素设置为给定值。
i - 索引newValue - 新值
public final void lazySet(int i,
int newValue)
i 的元素设置为给定值。
i - 索引newValue - 新值
public final int getAndSet(int i,
int newValue)
i 的元素以原子方式设置为给定值,并返回旧值。
i - 索引newValue - 新值
public final boolean compareAndSet(int i,
int expect,
int update)
== 预期值,则以原子方式将位置 i 的元素设置为给定的更新值。
i - 索引expect - 预期值update - 新值
public final boolean weakCompareAndSet(int i,
int expect,
int update)
== 预期值,则以原子方式将位置 i 的元素设置为给定的更新值。
可能意外失败并且不提供排序保证,所以只是在很少的情况下才对 compareAndSet 进行适当地选择。
i - 索引expect - 预期值update - 新值
public final int getAndIncrement(int i)
i 的元素加 1。
i - 索引
public final int getAndDecrement(int i)
i 的元素减 1。
i - 索引
public final int getAndAdd(int i,
int delta)
i 的元素相加。
i - 索引delta - 要加上的值
public final int incrementAndGet(int i)
i 的元素加 1。
i - 索引
public final int decrementAndGet(int i)
i 的元素减 1。
i - 索引
public final int addAndGet(int i,
int delta)
i 的元素相加。
i - 索引delta - 要加上的值
public String toString()
Object 中的 toString
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。