T
-客体可更新的字段的类型
public abstract class AtomicIntegerFieldUpdater<T> extends Object
volatile int
字段指定的类。此类被设计用于原子数据结构中,在该结构中,同一节点的几个字段独立地受原子更新。
值得注意的是,在这类的compareAndSet
方法保证弱于其他原子类。因为这类不能确保所有的字段都适合原子访问的目的,它可以保证原子性只有在同一更新相对于compareAndSet
和set
其他调用。
Modifier | Constructor and Description |
---|---|
protected |
AtomicIntegerFieldUpdater()
受保护的无构造函数使用的子类。
|
Modifier and Type | Method and Description |
---|---|
int |
accumulateAndGet(T obj, int x, IntBinaryOperator accumulatorFunction)
自动更新给定对象的更新管理与应用给出的函数的电流与给定值结果领域,返回更新后的值。
|
int |
addAndGet(T obj, int delta)
自动添加给定值对给定对象的更新管理领域的当前值。
|
abstract boolean |
compareAndSet(T obj, int expect, int update)
自动设置给定对象的这个更新设法给出更新的价值领域如果电流值
== 期望值。
|
int |
decrementAndGet(T obj)
自动递减一个给定对象的更新管理这一领域目前的价值。
|
abstract int |
get(T obj)
获取当前值在给定对象的更新管理领域举行。
|
int |
getAndAccumulate(T obj, int x, IntBinaryOperator accumulatorFunction)
自动更新给定对象的更新管理与应用给出的函数的电流与给定值结果领域,返回前一个值。
|
int |
getAndAdd(T obj, int delta)
自动添加给定值对给定对象的更新管理领域的当前值。
|
int |
getAndDecrement(T obj)
自动递减一个给定对象的更新管理这一领域目前的价值。
|
int |
getAndIncrement(T obj)
自动递增一个给定对象的更新管理这一领域目前的价值。
|
int |
getAndSet(T obj, int newValue)
自动设置现场给定对象的更新管理给定的值并返回旧值。
|
int |
getAndUpdate(T obj, IntUnaryOperator updateFunction)
自动更新领域的给定对象的更新管理与应用结果给定的函数,返回前一个值。
|
int |
incrementAndGet(T obj)
自动递增一个给定对象的更新管理这一领域目前的价值。
|
abstract void |
lazySet(T obj, int newValue)
最终设置给定对象的更新设法给出更新的价值领域。
|
static <U> AtomicIntegerFieldUpdater<U> |
newUpdater(类<U> tclass, String fieldName)
创建并返回与给定的领域对象的更新。
|
abstract void |
set(T obj, int newValue)
设置给定对象的更新设法给出更新的价值领域。
|
int |
updateAndGet(T obj, IntUnaryOperator updateFunction)
自动更新领域的给定对象的更新管理与应用结果给定的函数,返回更新后的值。
|
abstract boolean |
weakCompareAndSet(T obj, int expect, int update)
自动设置给定对象的这个更新设法给出更新的价值领域如果电流值
== 期望值。
|
public static <U> AtomicIntegerFieldUpdater<U> newUpdater(类<U> tclass, String fieldName)
U
-实例类型TClass
tclass
-控股的领域对象的类
fieldName
-字段的名字被更新
IllegalArgumentException
如果字段不挥发性的整数类型
RuntimeException
-嵌套的基于反射的异常,如果类没有场或是错误的类型,或该领域无法调用java语言根据访问控制
public abstract boolean compareAndSet(T obj, int expect, int update)
==
期望值。这种方法可以保证原子相对于其他呼叫
compareAndSet
和
set
,但不一定就在该领域的其他变化。
obj
-一个对象的字段条件设置
expect
-期望值
update
-新价值
true
如果成功
ClassCastException
-如果
obj
不是类的构造函数中建立具有现场实例
public abstract boolean weakCompareAndSet(T obj, int expect, int update)
==
期望值。这种方法可以保证原子相对于其他呼叫
compareAndSet
和
set
,但不一定就在该领域的其他变化。
May fail spuriously and does not provide ordering guarantees,所以只有很少compareAndSet
适当的替代。
obj
-一个对象的字段条件设置
expect
-期望值
update
-新价值
true
如果成功
ClassCastException
-如果
obj
不是类的构造函数中建立具有现场实例
public abstract void set(T obj, int newValue)
compareAndSet
挥发性存储。
obj
-一个对象的域设置
newValue
-新价值
public abstract void lazySet(T obj, int newValue)
obj
-一个对象的域设置
newValue
-新价值
public abstract int get(T obj)
obj
-一个对象的领域有
public int getAndSet(T obj, int newValue)
obj
-一个对象的字段来获取和设置
newValue
-新价值
public int getAndIncrement(T obj)
obj
-一个对象的字段来获取和设置
public int getAndDecrement(T obj)
obj
-一个对象的字段来获取和设置
public int getAndAdd(T obj, int delta)
obj
-一个对象的字段来获取和设置
delta
-加值
public int incrementAndGet(T obj)
obj
-一个对象的字段来获取和设置
public int decrementAndGet(T obj)
obj
-一个对象的字段来获取和设置
public int addAndGet(T obj, int delta)
obj
-一个对象的字段来获取和设置
delta
-价值增加
public final int getAndUpdate(T obj, IntUnaryOperator updateFunction)
obj
-一个对象的字段来获取和设置
updateFunction
-无副作用的功能
public final int updateAndGet(T obj, IntUnaryOperator updateFunction)
obj
-一个对象的字段来获取和设置
updateFunction
-无副作用的功能
public final int getAndAccumulate(T obj, int x, IntBinaryOperator accumulatorFunction)
obj
-一个对象的字段来获取和设置
x
-更新价值
accumulatorFunction
-两参数无副作用的功能
public final int accumulateAndGet(T obj, int x, IntBinaryOperator accumulatorFunction)
obj
-一个对象的字段来获取和设置
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.