[英]What are the differences between the volatile in c# and java?
In some .net documentation I have read this is how the compiler handles volatile: 在一些.net文档中,我读到了编译器如何处理volatile的方法:
These fences apply at both complier and architecture level. 这些围栏适用于编译器级别和体系结构级别。
Of course the main difference in VC++ is that the fence is only applied at complier level. 当然,VC ++的主要区别是,防护仅在编译器级别应用。
So my question is, what are the memory reordering prevention semantics of volatile in Java? 所以我的问题是,Java中volatile的防止内存重新排序的语义是什么?
Conversion: 转换:
Fence = Barrier Barrier = Fence 栅栏=栅栏栅栏=栅栏
References: 参考文献:
Joe Duffy (Concurrent Programming on Windows) Joe Duffy(Windows上的并发编程)
In Java, the javac
compiler does next to nothing with volatile. 在Java中,
javac
编译器javac
不使用volatile。 It doesn't re-order statements and does almost no optimisation. 它不会重新排序语句,并且几乎不会进行优化。
The JIT on the other hand can do quite a bit of optimisation and re-ordering. 另一方面,JIT可以进行很多优化和重新排序。
The important features of volatile
are; volatile
的重要特征是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.