iEverX / ieverx.github.io

0 stars 1 forks source link

post/2017/memory-barrier-in-synchronized/ #3

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

Synchronized 的内存屏障

https://blog.guolx.com/post/2017/memory-barrier-in-synchronized/

wezhyn commented 4 years ago

应该是JVM 的主动刷新工作内存与主内存,我在使用 -Xint 纯解释器模式后,

        @Override
        public void run() {
            while (!stop) {
            }
            System.out.println("stop");
        }

依旧能够输出 "stop",或许也跟操作系统中缓存行的刷新有关