Usage of volatile specifier in C/C++/Java

后端 未结 8 1559
旧时难觅i
旧时难觅i 2021-01-03 01:35

While going through many resources on multithreaded programming, reference to volatile specifier usually comes up. It is clear that usage of this keyword is not a reliable w

8条回答
  •  感情败类
    2021-01-03 02:12

    There is a good explanation here: http://en.wikipedia.org/wiki/Volatile_variable but slightly simplified it tells the compiler that it should not assume that the variable isn't accessed by someone else and that it is fatal to optimize it into a registrer and update only the register and not the actual storage.

提交回复
热议问题