|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。