java - volatile关键字的使用误区?
PHP中文网
PHP中文网 2017-04-18 09:51:22
0
3
559

在tij中的volatile中有这么一句话:

当一个域依赖于它之前的值时(如自增), 那么volatile就无法工作了. 如果某个域的值受到其他域的值的限制, 那么volatile也无法工作, 例如Range类的lower和upper边界值必须遵循lower<=upper

这段话想要表达的意思是什么?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
刘奇

In layman’s terms, values ​​marked as volatile may change unpredictably, so they cannot be cached and should be read from main memory each time.
Auto-increment operation, this value may change between reading and writing, so the correct result cannot be written.
Again, this value changes uncontrollably, so the invariant may not be satisfied.

迷茫

It should be that volatilethe atomicity of the operation cannot be guaranteed

洪涛

See: The meaning of volatile keyword in java

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!