Is there any advantage of using volatile keyword in contrast to use the Interlocked class?

后端 未结 5 1894
时光取名叫无心
时光取名叫无心 2021-02-04 15:59

In other words, can I do something with a volatile variable that could not also be solved with a normal variable and the Interlocked class?

5条回答
  •  灰色年华
    2021-02-04 16:29

    I won't attempt to be an authority on this subject but I would highly recommend that you take a look at this article by the vaunted Jon Skeet.

    Also take a look at the final part of this answer which details what volatile should be used for.

提交回复
热议问题