|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.util.concurrent.atomic.AtomicStampedReference<V>
V - 此參考所參考的物件型別public class AtomicStampedReference<V>
AtomicStampedReference 維護帶有整數「標誌」的物件參考,可以用原子方式對其進行更新。
實作注意事項。通過創建表示「已裝箱」的 [reference, integer] 對的內部物件,此實作維持帶標誌的參考。
| 建構子摘要 | |
|---|---|
AtomicStampedReference(V initialRef,
int initialStamp)
創建具有給定初始值的新 AtomicStampedReference。 |
|
| 方法摘要 | |
|---|---|
boolean |
attemptStamp(V expectedReference,
int newStamp)
如果當前參考 == 預期參考,則以原子方式將該標誌的值設置為給定的更新值。 |
boolean |
compareAndSet(V expectedReference,
V newReference,
int expectedStamp,
int newStamp)
如果當前參考 == 預期參考,並且當前標誌等於預期標誌,則以原子方式將該參考和該標誌的值設置為給定的更新值。 |
V |
get(int[] stampHolder)
返回該參考和該標誌的當前值。 |
V |
getReference()
返回該參考的當前值。 |
int |
getStamp()
返回該標誌的當前值。 |
void |
set(V newReference,
int newStamp)
無條件地同時設置該參考和標誌的值。 |
boolean |
weakCompareAndSet(V expectedReference,
V newReference,
int expectedStamp,
int newStamp)
如果當前參考 == 預期參考,並且當前標誌等於預期標誌,則以原子方式將該參考和該標誌的值設置為給定的更新值。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 建構子詳細資訊 |
|---|
public AtomicStampedReference(V initialRef,
int initialStamp)
AtomicStampedReference。
initialRef - 初始參考initialStamp - 初始標誌| 方法詳細資訊 |
|---|
public V getReference()
public int getStamp()
public V get(int[] stampHolder)
int[1] holder; ref = v.get(holder); 。
stampHolder - 大小至少為 1 的陣列。返回時,stampholder[0] 將保存該標誌的值。
public boolean weakCompareAndSet(V expectedReference,
V newReference,
int expectedStamp,
int newStamp)
== 預期參考,並且當前標誌等於預期標誌,則以原子方式將該參考和該標誌的值設置為給定的更新值。
可能意外失敗並且不提供排序保證,所以只有在很少的情況下才對 compareAndSet 進行適當的選擇。
expectedReference - 該參考的預期值newReference - 該參考的新值expectedStamp - 該標誌的預期值newStamp - 該標誌的新值
public boolean compareAndSet(V expectedReference,
V newReference,
int expectedStamp,
int newStamp)
== 預期參考,並且當前標誌等於預期標誌,則以原子方式將該參考和該標誌的值設置為給定的更新值。
expectedReference - 該參考的預期值newReference - 該參考的新值expectedStamp - 該標誌的預期值newStamp - 該標誌的新值
public void set(V newReference,
int newStamp)
newReference - 該參考的新值newStamp - 該標誌的新值
public boolean attemptStamp(V expectedReference,
int newStamp)
== 預期參考,則以原子方式將該標誌的值設置為給定的更新值。此操作的任何給定調用都可能會意外失敗(返回 false),但是在當前值保持預期值而且沒有其他執行緒也在嘗試設置該值時,重複調用將最終獲得成功。
expectedReference - 該參考的預期值newStamp - 該標誌的新值
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。