E
-基类元素在数组
public class AtomicReferenceArray<E> extends Object implements Serializable
java.util.concurrent.atomic
包装规范。
Constructor and Description |
---|
AtomicReferenceArray(E[] array)
创建具有相同的长度作为一个新的AtomicReferenceArray,和所有的元素复制,给定的数组。
|
AtomicReferenceArray(int length)
创建一个新的AtomicReferenceArray给定长度的所有元素,最初为空。
|
Modifier and Type | Method and Description |
---|---|
E |
accumulateAndGet(int i, E x, BinaryOperator<E> accumulatorFunction)
自动更新与应用给出的函数的电流与给定值的结果指标
i 元素,返回更新后的值。
|
boolean |
compareAndSet(int i, E expect, E update)
自动设置元素的位置
i 给更新后的值,如果电流值
== 期望值。
|
E |
get(int i)
获取位置
i 电流值。
|
E |
getAndAccumulate(int i, E x, BinaryOperator<E> accumulatorFunction)
自动更新与应用给出的函数的电流与给定值的结果指标
i 元素,返回前一个值。
|
E |
getAndSet(int i, E newValue)
自动设置元素的位置
i 到给定值并返回旧值。
|
E |
getAndUpdate(int i, UnaryOperator<E> updateFunction)
自动更新的元素在指数
i 结果应用给定的函数,返回前一个值。
|
void |
lazySet(int i, E newValue)
最终集的元素在位置
i 到给定值。
|
int |
length()
返回数组的长度。
|
void |
set(int i, E newValue)
设置元素的位置
i 到给定值。
|
String |
toString()
返回数组当前值的字符串表示形式。
|
E |
updateAndGet(int i, UnaryOperator<E> updateFunction)
自动更新的元素在指数
i 结果应用给定的函数,返回更新后的值。
|
boolean |
weakCompareAndSet(int i, E expect, E update)
自动设置元素的位置
i 给更新后的值,如果电流值
== 期望值。
|
public AtomicReferenceArray(int length)
length
-数组的长度
public AtomicReferenceArray(E[] array)
array
-阵列复制元素
NullPointerException
如果数组为空
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
-新价值
true
如果成功。错误返回表示实际值不等于期望值。
public final boolean weakCompareAndSet(int i, E expect, E update)
i
给更新后的值,如果电流值
==
期望值。
May fail spuriously and does not provide ordering guarantees,所以很少有合适的替代compareAndSet
。
i
-指数
expect
-期望值
update
-新价值
true
如果成功
public final E getAndUpdate(int i, UnaryOperator<E> updateFunction)
i
结果应用给定的函数,返回前一个值。函数应该是免费的,因为它可能会被重新应用时尝试更新失败,由于线程之间的争用。
i
-指数
updateFunction
-无副作用的功能
public final E updateAndGet(int i, UnaryOperator<E> updateFunction)
i
结果应用给定的函数,返回更新后的值。函数应该是免费的,因为它可能会被重新应用时尝试更新失败,由于线程之间的争用。
i
-指数
updateFunction
-无副作用的功能
public final E getAndAccumulate(int i, E x, BinaryOperator<E> accumulatorFunction)
i
元素,返回前一个值。函数应该是免费的,因为它可能会被重新应用时尝试更新失败,由于线程之间的争用。应用函数与当前价值指标
i
作为其第一个参数,并给出更新作为第二个参数。
i
-指数
x
-更新价值
accumulatorFunction
-两参数无副作用的功能
public final E accumulateAndGet(int i, E x, BinaryOperator<E> accumulatorFunction)
i
元素,返回更新后的值。函数应该是免费的,因为它可能会被重新应用时尝试更新失败,由于线程之间的争用。应用函数与当前价值指标
i
作为其第一个参数,并给出更新作为第二个参数。
i
-指数
x
-更新价值
accumulatorFunction
-两参数无副作用的功能
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.