synchronized block not locking the object reference
问题 class Demo { void demo() { System.out.println("Inside demo of "+Thread.currentThread().getName()); try { Thread.sleep(1000000); } catch(InterruptedException exc) { System.out.println(Thread.currentThread().getName()+" interrupted"); } } } class MyThread1 implements Runnable { Thread thread; Demo d; MyThread1(String name, Demo ob) { d = ob; thread = new Thread(this, name); thread.start(); } @Override public void run() { System.out.println(thread.getName()+" starting"); synchronized(d) { d.demo