|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.util.concurrent.atomic.AtomicReferenceArray<E>
E - 此陣列中所保持元素的基礎類別public class AtomicReferenceArray<E>
可以用原子方式更新其元素的物件參考陣列。有關原子變數屬性的描述,請參閱 java.util.concurrent.atomic 套件規範。
| 建構子摘要 | |
|---|---|
AtomicReferenceArray(E[] array)
創建與給定陣列具有相同長度的新 AtomicReferenceArray,並從給定陣列複製其所有元素。 |
|
AtomicReferenceArray(int length)
創建給定長度的新 AtomicReferenceArray。 |
|
| 方法摘要 | |
|---|---|
boolean |
compareAndSet(int i,
E expect,
E update)
如果當前值 == 預期值,則以原子方式將位置 i 的元素設置為給定的更新值。 |
E |
get(int i)
獲取位置 i 的當前值。 |
E |
getAndSet(int i,
E newValue)
以原子方式將位置 i 的元素設置為給定值,並返回舊值。 |
void |
lazySet(int i,
E newValue)
最終將位置 i 的元素設置為給定值。 |
int |
length()
返回該陣列的長度。 |
void |
set(int i,
E newValue)
將位置 i 的元素設置為給定值。 |
String |
toString()
返回陣列當前值的字元串表示形式。 |
boolean |
weakCompareAndSet(int i,
E expect,
E update)
如果當前值 == 預期值,則以原子方式將位置 i 的元素設置為給定的更新值。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 建構子詳細資訊 |
|---|
public AtomicReferenceArray(int length)
length - 該陣列的長度public AtomicReferenceArray(E[] array)
array - 從中複製元素的陣列
NullPointerException - 如果陣列為 null| 方法詳細資訊 |
|---|
public final int length()
public final E get(int i)
i 的當前值。
i - 索引
public final void set(int i,
E newValue)
i 的元素設置為給定值。
i - 索引newValue - 新值
public final void lazySet(int i,
E newValue)
i 的元素設置為給定值。
i - 索引newValue - 新值
public final E getAndSet(int i,
E newValue)
i 的元素設置為給定值,並返回舊值。
i - 索引newValue - 新值
public final boolean compareAndSet(int i,
E expect,
E update)
== 預期值,則以原子方式將位置 i 的元素設置為給定的更新值。
i - 索引expect - 預期值update - 新值
public final boolean weakCompareAndSet(int i,
E expect,
E update)
== 預期值,則以原子方式將位置 i 的元素設置為給定的更新值。
可能意外失敗並且不提供排序保證,因此幾乎只是 compareAndSet 的適當替換方法。
i - 索引expect - 預期值update - 新值
public String toString()
Object 中的 toString
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。