AtomicLongArray.GetAndAccumulate(Int32, Int64, ILongBinaryOperator) 方法

定义

以原子方式更新(由索引i处指定的VarHandle#compareAndSet内存效果),结果将给定函数应用于当前值和给定值,并返回以前的值。

[Android.Runtime.Register("getAndAccumulate", "(IJLjava/util/function/LongBinaryOperator;)J", "", ApiSince=24)]
public long GetAndAccumulate(int i, long x, Java.Util.Functions.ILongBinaryOperator? accumulatorFunction);
[<Android.Runtime.Register("getAndAccumulate", "(IJLjava/util/function/LongBinaryOperator;)J", "", ApiSince=24)>]
member this.GetAndAccumulate : int * int64 * Java.Util.Functions.ILongBinaryOperator -> int64

参数

i
Int32

索引

x
Int64

更新值

accumulatorFunction
ILongBinaryOperator

两个参数的无副作用函数

返回

上一个值

属性

注解

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

已在 1.8 中添加。

Java文档java.util.concurrent.atomic.AtomicLongArray.getAndAccumulate(int, long, java.util.function.LongBinaryOperator)

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

适用于