V
-对象的类型称为参考
public class AtomicReference<V> extends Object implements Serializable
java.util.concurrent.atomic
包装规范。
Constructor and Description |
---|
AtomicReference()
创建具有零初始值的一种新的atomicreference。
|
AtomicReference(V initialValue)
创建具有给定的初始值的一种新的AtomicReference。
|
Modifier and Type | Method and Description |
---|---|
V |
accumulateAndGet(V x, BinaryOperator<V> accumulatorFunction)
自动更新当前值与给定的功能应用到当前和给定值的结果,返回更新后的值。
|
boolean |
compareAndSet(V expect, V update)
自动设置的值来指定更新值,如果电流值
== 期望值。
|
V |
get()
获取当前值。
|
V |
getAndAccumulate(V x, BinaryOperator<V> accumulatorFunction)
自动更新当前值与给定的功能应用到当前和给定值的结果,返回前一个值。
|
V |
getAndSet(V newValue)
自动设置为给定的值并返回旧值。
|
V |
getAndUpdate(UnaryOperator<V> updateFunction)
自动更新当前值与结果应用给定的函数,返回前一个值。
|
void |
lazySet(V newValue)
最终设置为给定的值。
|
void |
set(V newValue)
给定值的集合。
|
String |
toString()
返回当前值的字符串表示形式。
|
V |
updateAndGet(UnaryOperator<V> updateFunction)
自动更新当前值与结果应用给定的函数,返回更新后的值。
|
boolean |
weakCompareAndSet(V expect, V update)
自动设置的值来指定更新值,如果电流值
== 期望值。
|
public AtomicReference(V initialValue)
initialValue
的初始值
public AtomicReference()
public final V get()
public final void set(V newValue)
newValue
-新价值
public final void lazySet(V newValue)
newValue
-新价值
public final boolean compareAndSet(V expect, V update)
==
期望值。
expect
-期望值
update
-新价值
true
如果成功。错误返回表示实际值不等于期望值。
public final boolean weakCompareAndSet(V expect, V update)
==
期望值。
May fail spuriously and does not provide ordering guarantees,所以只有很少compareAndSet
适当的替代。
expect
-期望值
update
-新价值
true
如果成功
public final V getAndUpdate(UnaryOperator<V> updateFunction)
updateFunction
-无副作用的功能
public final V updateAndGet(UnaryOperator<V> updateFunction)
updateFunction
-无副作用的功能
public final V getAndAccumulate(V x, BinaryOperator<V> accumulatorFunction)
x
-更新价值
accumulatorFunction
-两参数无副作用的功能
public final V accumulateAndGet(V x, BinaryOperator<V> accumulatorFunction)
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.