AtomicInteger.UpdateAndGet(IIntUnaryOperator) 方法

定义

以原子方式更新(由指定的 VarHandle#compareAndSet内存效果)当前值,其结果为应用给定函数,并返回更新的值。

[Android.Runtime.Register("updateAndGet", "(Ljava/util/function/IntUnaryOperator;)I", "", ApiSince=24)]
public int UpdateAndGet(Java.Util.Functions.IIntUnaryOperator? updateFunction);
[<Android.Runtime.Register("updateAndGet", "(Ljava/util/function/IntUnaryOperator;)I", "", ApiSince=24)>]
member this.UpdateAndGet : Java.Util.Functions.IIntUnaryOperator -> int

参数

updateFunction
IIntUnaryOperator

无副作用函数

返回

更新的值

属性

注解

以原子方式更新(由指定的 VarHandle#compareAndSet内存效果)当前值,其结果为应用给定函数,并返回更新的值。 该函数应无副作用,因为当尝试更新因线程之间的争用而失败时,可能会重新应用该函数。

已在 1.8 中添加。

适用于 . 的 java.util.concurrent.atomic.AtomicInteger.updateAndGet(java.util.function.IntUnaryOperator)Java 文档

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

适用于