語言

AtomicInteger.WeakCompareAndSet(Int32, Int32) 方法

定義

可能原子上將值設定為 newValue 當前值 == expectedValue,並以記憶體效應 VarHandle#weakCompareAndSetPlain指定。

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

參數

expectedValue
Int32

期望值

newValue
Int32

新值

傳回

true 若成功

屬性

備註

可能原子上將值設定為 newValue 當前值 == expectedValue,並以記憶體效應 VarHandle#weakCompareAndSetPlain指定。

此會員已被棄用。 此方法具有純粹的記憶體效應,但其名稱暗示揮發性記憶體效應(參見如 #compareAndExchange#compareAndSet等方法)。 為避免對純記憶或揮發性記憶效應產生混淆,建議採用此方法 #weakCompareAndSetPlain

Java 文件 java.util.concurrent.atomic.AtomicInteger.weakCompareAndSet(int, int)

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

適用於