語言

AtomicLongFieldUpdater.UpdateAndGet(Object, ILongUnaryOperator) 方法

定義

根據該更新器所管理的物件欄位,根據該函式的應用結果,原子方式更新(並以記憶體效果 VarHandle#compareAndSet)回傳更新後的值。

[Android.Runtime.Register("updateAndGet", "(Ljava/lang/Object;Ljava/util/function/LongUnaryOperator;)J", "", ApiSince=24)]
public long UpdateAndGet(Java.Lang.Object? obj, Java.Util.Functions.ILongUnaryOperator? updateFunction);
[<Android.Runtime.Register("updateAndGet", "(Ljava/lang/Object;Ljava/util/function/LongUnaryOperator;)J", "", ApiSince=24)>]
member this.UpdateAndGet : Java.Lang.Object * Java.Util.Functions.ILongUnaryOperator -> int64

參數

obj
Object

一個要取得並設定其場的物件

updateFunction
ILongUnaryOperator

一個無副作用函數

傳回

更新後的數值

屬性

備註

根據該更新器所管理的物件欄位,根據該函式的應用結果,原子方式更新(並以記憶體效果 VarHandle#compareAndSet)回傳更新後的值。 此函式應無副作用,因為當嘗試更新因執行緒間爭用失敗時,可重新套用此功能。

新增於1.8版本。

Java 文件 java.util.concurrent.atomic.AtomicLongFieldUpdater.updateAndGet(T, java.util.function.LongUnaryOperator)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於