語言

AtomicInteger.CompareAndSet(Int32, Int32) 方法

定義

原子上將值設定為 newValue 當前值 == expectedValue,記憶體效果則由 指定 VarHandle#compareAndSet

[Android.Runtime.Register("compareAndSet", "(II)Z", "")]
public bool CompareAndSet(int expectedValue, int newValue);
[<Android.Runtime.Register("compareAndSet", "(II)Z", "")>]
member this.CompareAndSet : int * int -> bool

參數

expectedValue
Int32

期望值

newValue
Int32

新值

傳回

如果成功,則為 true。 錯誤回傳表示實際值不等於預期值。

屬性

備註

原子上將值設定為 newValue 當前值 == expectedValue,記憶體效果則由 指定 VarHandle#compareAndSet

java.util.concurrent.atomic.AtomicInteger.compareAndSet(int, int)Java 檔。

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

適用於