AtomicIntegerFieldUpdater.GetAndAccumulate 方法

定义

以原子方式更新(由指定内存效果)由此更新程序管理的 VarHandle#compareAndSet给定对象的字段,并将给定函数应用于当前值和给定值的结果,并返回上一个值。

[Android.Runtime.Register("getAndAccumulate", "(Ljava/lang/Object;ILjava/util/function/IntBinaryOperator;)I", "", ApiSince=24)]
public int GetAndAccumulate(Java.Lang.Object? obj, int x, Java.Util.Functions.IIntBinaryOperator? accumulatorFunction);
[<Android.Runtime.Register("getAndAccumulate", "(Ljava/lang/Object;ILjava/util/function/IntBinaryOperator;)I", "", ApiSince=24)>]
member this.GetAndAccumulate : Java.Lang.Object * int * Java.Util.Functions.IIntBinaryOperator -> int

参数

obj
Object

要获取和设置其字段的对象

x
Int32

更新值

accumulatorFunction
IIntBinaryOperator

两个参数的无副作用函数

返回

上一个值

属性

注解

以原子方式更新(由指定内存效果)由此更新程序管理的 VarHandle#compareAndSet给定对象的字段,并将给定函数应用于当前值和给定值的结果,并返回上一个值。 该函数应无副作用,因为当尝试更新因线程之间的争用而失败时,可能会重新应用该函数。 该函数应用当前值作为第一个参数,将给定更新作为第二个参数。

已在 1.8 中添加。

Java文档java.util.concurrent.atomic.AtomicIntegerFieldUpdater.getAndAccumulate(T, int, java.util.function.IntBinaryOperator)

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于