Performance of Interlocked.Increment

后端 未结 6 1978
陌清茗
陌清茗 2020-12-15 18:30

Is Interlocked.Increment(ref x) faster or slower than x++ for ints and longs on various platforms?

6条回答
  •  一整个雨季
    2020-12-15 19:03

    It's slower. However, it's the most performant general way I know of for achieving thread safety on scalar variables.

提交回复
热议问题