Java synchronized and static synchronized method accessing static field
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What would be the behaviour of the following program where static synchronized method and instance synchronized method is trying to access static field of same class in different threads? Will any thread get blocked? Its very confusing. class MyClass { public static int i = 5; public synchronized void m1() { System.out.println(i); //uses static field i of MyClass //T1 is executing this method } public static synchronized void m3() { //T2 will be able to call this method on same object lock while it is using //static field i??? System.out