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