What is “Locked ownable synchronizers” in thread dump?

后端 未结 3 1289
南笙
南笙 2021-02-01 03:21

I am trying to understand what does Locked ownable synchronizers refer to in a thread dump?

I started using ReentrantReadWriteLock have a thread in WA

3条回答
  •  再見小時候
    2021-02-01 03:52

    Correct use ReentrantLock it isn't so easy as it seems. It has several pitfalls. If we speak about deadlocks i think you need to know :

    1.

    The main explanation we found at this point is associated with the usage of the ReentrantLock READ lock. The read locks are normally not designed to have a notion of ownership. Since there is not a record of which thread holds a read lock, this appears to prevent the HotSpot JVM deadlock detector logic to detect deadlock involving read locks.

    Some improvements were implemented since then but we can see that the JVM still cannot detect this special deadlock scenario.

    It's from nice article "Java concurrency: the hidden thread deadlocks"

    If you have access to source code getReadHoldCount() method can help in investigation deadlocks.

    2. Correct upgrade from readLock to writeLock - "Java ReentrantReadWriteLocks - how to safely acquire write lock?"

提交回复
热议问题