Cache flush on synchronized entry ,exit and volatile read and write
问题 When synchronized block execution is completed all the processor cache is flushed or only that object on which synchronized statement acted on will be flushed? In the below example when thread finished execution of method2 does data of obj2 is also flushed to the main memory? class cls1 { int x=10; } class cls2{ int y=10; } class cls3{ cls1 obj1; cls2 obj2; public void method2(){ obj2.y=10; synchronized(obj1){ obj1.x=30; } } public static void main(String[] args) { final cls3 obj3 = new cls3(