英文的原话是: Because the doSomething methods in Widget and LoggingWidget are both synchronized, each tries to acquire the lock on the Widget before proceeding. 我咋感觉应该是lock on the LoggingWidget 而不是Widget呢?
锁对象确实是LoggingWidget,也许这里原文是个笔误,也许是用父类引用泛指子类对象这样来描述的 《Java Concurrency in Practise》的这一处确实给不少人带来了疑惑。
Because the doSomething methods in Widget and LoggingWidget are both synchronized, each tries to acquire the lock on the Widget before proceeding. 我咋感觉应该是lock on the LoggingWidget 而不是Widget呢?
锁对象确实是LoggingWidget,也许这里原文是个笔误,也许是用父类引用泛指子类对象这样来描述的
《Java Concurrency in Practise》的这一处确实给不少人带来了疑惑。