What is the purpose of 'volatile' keyword in C#

前端 未结 6 2216
抹茶落季
抹茶落季 2020-12-05 15:23

What is the purpose of volatile keyword in C#?

Where would I need to use this keyword?

I saw the following statement, but I am unable to underst

6条回答
  •  萌比男神i
    2020-12-05 15:36

    It indicates that the value may get changed by a different thread, so the value needs to be read even if a previous instruction has already read it.

    http://msdn.microsoft.com/en-us/library/x13ttww7%28VS.71%29.aspx

提交回复
热议问题