对synchronized(this)的一些理解(6) } } }
结果:
t1 : 4t1 : 3t1 : 2t1 : 1t1 : 0t2 : 4t2 : 3t2 : 2t2 : 1t2 : 0
五、以上规则对其它对象锁同样适用:
package ths;
public class Thread3 { class Inner { private void m4t1() { int i = 5; while(i-- > 0) { System.out.println(Thread.currentThread().getName() + " : Inner.m4t1()=" + i); try { Thread.sleep(500); } catch(InterruptedException ie) { } } } private void m4t2() { int i = 5; while(i-- > 0) {