Java thread dump: Difference between “waiting to lock” and “parking to wait for”?

前端 未结 2 569
小蘑菇
小蘑菇 2021-01-30 05:23

In a Java thread dump, you can see locks mentioned within stack traces.
There seems to be three kinds of information:

1:

- locked <0x00002aab329f7         


        
2条回答
  •  北海茫月
    2021-01-30 05:38

    In my opinion, the java.util.concurrent package almost use LockSupport.park() method to block thread, such as CountDownLatch, ReentrantLock which belong to abstractqueuedsynchronized framework. Thus, the 3rd scenario in your questions means your code finally calls LockSupport.park() method, for you use the concurrent class in java.util.concurrent package, the 2nd scenario means you use synchronized keywork and call wait() method explicitly.

提交回复
热议问题