gpt4 book ai didi

c# - Interlocked.CompareExchange 如果不相等?

转载 作者:太空宇宙 更新时间:2023-11-03 17:43:03 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Interlocked.CompareExchange<Int> using GreaterThan or LessThan instead of equality

我知道 Interlocked.CompareExchange 只有在值和比较数相等时才交换值,
如果它们不相等,如何交换它们以达到这样的目的?

if (Interlocked.CompareExchange(ref count, count + 1, max) != max)
// i want it to increment as long as it is not equal to max
{
//count should equal to count + 1
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com