英文:
ReEntrantLcoks-What is the use of having multiple locks on the same object
问题
在浏览了 ReentrantLock
的优势之一时,
> 使用 ReentrantLock,线程可以多次在同一对象上获得锁。
我遇到了这个回答,其中指出 get(index)
方法会发生死锁。如果在 get(index)
上没有使用任何同步,有人可以解释一下在这一点上如何发生死锁吗?
英文:
While going through the advantages of ReEntrantLock
one of them is:
> With ReentrantLock, a thread can acquire lock on the same object more
> than once.
I came across this answer which states that there would be a deadlock in the get(index)
. Can someone please explain how can a deadlock occur at that point, if we are not using any synchronization
on get(index)
?
专注分享java语言的经验与见解,让所有开发者获益!
评论