volatileall of the defined variables are in memory,For example:int i = ten;int J = i;int k = i; i = 10; is the initialized variable, stored in the data segment, the uninitialized variable is stored in the BSS segmentThat is, I was left in memory.J = i at this time I is the right value, then the value of I on the register, J is from the register above the valueThe compiler may cause the value on the Register to change during compilation, then the value that K takes is not what we want.If you add a volatile int k = i;then k each time from the memory value, to ensure the correctness of the value
Sina Blog: http://blog.sina.com.cn/u/2049150530
CSDN Blog: http://blog.csdn.net/u011749143
Blog Park: http://www.cnblogs.com/sky-heaven/
Sina Weibo: Zhang Zhanhua--sky
Know: Http://www.zhihu.com/people/zhang-bing-hua
Deep understanding of volatile-"sky original"