AtomicReferenceArray.CompareAndExchange(Int32, Object, Object) 方法

定义

以原子方式将索引处 i 的元素设置为 newValue 元素的当前值(称为 <em>见证值</em>), == expectedValue内存效果由指定 VarHandle#compareAndExchange

[Android.Runtime.Register("compareAndExchange", "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "", ApiSince=33)]
public Java.Lang.Object? CompareAndExchange (int i, Java.Lang.Object? expectedValue, Java.Lang.Object? newValue);
[<Android.Runtime.Register("compareAndExchange", "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "", ApiSince=33)>]
member this.CompareAndExchange : int * Java.Lang.Object * Java.Lang.Object -> Java.Lang.Object

参数

i
Int32

索引

expectedValue
Object

预期值

newValue
Object

新值

返回

见证值,如果成功,则该值与预期值相同

属性

注解

以原子方式将索引处 i 的元素设置为 newValue 元素的当前值(称为 <em>见证值</em>), == expectedValue内存效果由指定 VarHandle#compareAndExchange

已在 9 中添加。

适用于 . 的 java.util.concurrent.atomic.AtomicReferenceArray.compareAndExchange(int, E, E)Java 文档

本页的某些部分是根据 Android 开放源代码项目创建和共享的工作进行的修改,并根据 Creative Commons 2.5 属性许可证中所述的术语使用。

适用于