volatile不会被直接编译成特殊的jvm指令

volatile不会被直接编译成特殊的jvm指令; 相反,它只是存在于bytecode中作为变量的属性。到运行时,JVM才根据这个属性来决定如何生成对应的汇编指令。比如说,看到这个属性就禁止指令重排

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.