Interlocked.CompareExchange using GreaterThan or LessThan instead of equality

后端 未结 7 1426
别跟我提以往
别跟我提以往 2020-12-24 07:23

The System.Threading.Interlocked object allows for Addition (subtraction) and comparison as an atomic operation. It seems that a CompareExchange that just does

7条回答
  •  忘掉有多难
    2020-12-24 07:42

    Greater/Less than and equal to are already atomic operations. That doesn't address the safe concurrent behavior of your application tho.

    There is no point in making them part of the Interlocked family, so the question is: what are you actually trying to achieve?

提交回复
热议问题