我在 Java 规范中看到了以下声明。
Programs where threads hold (directly or indirectly) locks on multiple objects should use conventional techniques for deadlock avoidance, creating higher-level locking primitives that don't deadlock, if necessary.
那么,避免死锁的“常规技术”是什么?我对此不是很清楚(没有正确理解,需要解释)。
最佳答案
最常见的技术是以某种一致的、明确定义的顺序获取资源(锁)。
Brian Goetz 的以下文章可能会有所帮助:http://www.javaworld.com/javaworld/jw-10-2001/jw-1012-deadlock.html
它很旧,但很好地解释了问题。
关于java - 什么是 "Conventional Techniques"来避免死锁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5155013/