Synchronized实现原理

查看带有Synchronized语句块的class文件能够看到在同步代码块的起始位置插入了moniterenter指令,在同步代码块结束的位置插入了monitorexit指令。(JVM须要保证每个monitorenter都有一个monitorexit与之相对应,但每一个monitorexit不必定都有一个monitorenter) 可是查看同步方法的class文件时,同步方法并无经过指令monit
相关文章
相关标签/搜索