Memory effects of synchronized keyword in Java
问题 This might have been answered before, but because of the complexity of the issue, I need a confirmation. So I rephrase the question Question 1 : When a thread enters a synchronized block, the memory barrier will include any fields touched, not just fields of the object that I synchronized on? So if many many objects are modified inside a synchronized block, that's a lot of memory moves between thread memory caches. Thread 1 object.field1 = ""; synchronized (lock) { farAwayObject.field1 = "";