但是同步还有另一个方面:正如JMM所指定,它强制实施某些内存可见性规则。
But synchronization also has another aspect: it enforces certain memory visibility rules as specified by the JMM.
注意,在同一个线程的不同方法之间传递对象的引用,永远也不会出现内存可见性问题。
Note that visibility problems never arise when passing references to objects across methods in the same thread.
可见性则更为微妙;它要对付内存缓存和编译器优化的各种反常行为。
Visibility is more subtle; it deals with the vagaries of memory caching and compiler optimizations.
应用推荐