问题描述
我读到某处x86处理器具有缓存一致性,并且每次写入时无论如何都可以跨多个内核同步字段的值。
I read somewhere that x86 processors have cache coherency and can sync the value of fields across multiple cores anyway on each write.
这意味着我们可以在不使用代码的情况下进行编码如果我们计划仅在x86处理器上运行,则在Java中使用易失性键域?
Does that mean that we can code without using the 'volatile' keywoard in java if we plan on running only on x86 processors?
更新:
好,假设我们不考虑指令重新排序的问题,是否可以假设x86处理器上不存在对非易失性字段的分配问题,而这些问题在内核中不可见?
Ok assuming that we leave out the issue of instruction reordering, can we assume that the issue of an assignment to a non-volatile field not being visible across cores is not present on x86 processors?
推荐答案
否- volatile
关键字的含义不仅仅是缓存一致性。它还限制了运行时可以做什么和不能做什么,例如延迟构造函数调用。
No -- the volatile
keyword has more implications than just cache coherency; it also places restrictions on what the runtime can and can't do, like delaying constructor calls.
这篇关于在x86处理器上无用的易失性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!