語言

AtomicInteger.AccumulateAndGet(Int32, IIntBinaryOperator) 方法

定義

原子式更新(依指定 VarHandle#compareAndSet記憶體效果)並以對現有值及給定值套用給定函式的結果,回傳更新後的值。

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

參數

x
Int32

更新值

accumulatorFunction
IIntBinaryOperator

兩個參數的無副作用函數

傳回

更新後的數值

屬性

備註

原子式更新(依指定 VarHandle#compareAndSet記憶體效果)並以對現有值及給定值套用給定函式的結果,回傳更新後的值。 此函式應無副作用,因為當嘗試更新因執行緒間爭用失敗時,可重新套用此功能。 函式以當前值作為第一個參數,並以該更新作為第二個參數套用。

新增於1.8版本。

java.util.concurrent.atomic.AtomicInteger.accumulateAndGet(int, java.util.function.IntBinaryOperator)Java 檔。

此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。

適用於