您的位置:首页 > 其它

volatile 关键字的使用

2012-11-07 15:52 197 查看

volatile 关键字的使用

volatile 从字面意思来看是“挥发性的”“不稳定的”。在一个变量前面加上这个关键字就是告诉 compiler, 这个变量是“不稳定的”,每次访问它的时候,都要去 memory 中重新读取它的值,而不能使用之前保存的该变量的暂时值。

Volatile is a "type qualifier". It tells the compiler that the variable might change without it knowing. The volatile qualifier tells the compiler that whenever you access the variable, its value has to be loaded from memory and that he may assume nothing about this value from previous stores it has effected.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: