共用方式為


AtomicLong.AccumulateAndGet(Int64, ILongBinaryOperator) 方法

定義

以不可部分完成的方式更新 (以 指定的 VarHandle#compareAndSet記憶體效果)目前值,並將指定的函式套用至目前和指定值的結果,並傳回更新的值。

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

參數

x
Int64

更新值

accumulatorFunction
ILongBinaryOperator

兩個自變數的無副作用函式

傳回

更新的值

屬性

備註

以不可部分完成的方式更新 (以 指定的 VarHandle#compareAndSet記憶體效果)目前值,並將指定的函式套用至目前和指定值的結果,並傳回更新的值。 函式應該是無副作用的,因為嘗試更新失敗時可能會因為線程之間的爭用而重新套用。 函式會套用目前值做為其第一個自變數,並將指定的更新套用為第二個自變數。

已在1.8中新增。

java.util.concurrent.atomic.AtomicLong.accumulateAndGet(long, java.util.function.LongBinaryOperator)Java 檔。

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

適用於