|
JavaTM 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 Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。