共用方式為


AtomicIntegerArray.GetAndUpdate(Int32, IIntUnaryOperator) 方法

定義

以不可部分完成的方式更新 (使用 指定的 VarHandle#compareAndSet記憶體效果)索引處 i 的專案,並傳回前一個值,以套用指定函式的結果。

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

參數

i
Int32

索引

updateFunction
IIntUnaryOperator

無副作用函式

傳回

上一個值

屬性

備註

以不可部分完成的方式更新 (使用 指定的 VarHandle#compareAndSet記憶體效果)索引處 i 的專案,並傳回前一個值,以套用指定函式的結果。 函式應該是無副作用的,因為嘗試更新失敗時可能會因為線程之間的爭用而重新套用。

已在1.8中新增。

java.util.concurrent.atomic.AtomicIntegerArray.getAndUpdate(int, java.util.function.IntUnaryOperator)Java 檔。

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

適用於