Why timed lock technique doesn't work if multiple locks are acquired due to the nesting of method calls

佐手、 提交于 2020-02-05 04:55:26

问题


Quote from java concurrency in practice:

Using timed lock acquisition to acquire multiple locks can be effective against deadlock even when timed locking is not used consistently throughout the program. If a lock acquisition times out, you can release the locks, back off and wait for a while, and try again, possibly clearing the deadlock condition and allowing the program to recover. (This technique works only when the two locks are acquired together; if multiple locks are acquired due to the nesting of method calls, you cannot just release the outer lock, even if you know you hold it.)

Can you clarify bolded text ?

Maybe it is my translation issue but I don't see explicit difference between 2 and 'multiple' locks and what the problem of nested method calls?

来源:https://stackoverflow.com/questions/42573218/why-timed-lock-technique-doesnt-work-if-multiple-locks-are-acquired-due-to-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!