Multiple Java threads seemingly locking same monitor?

前端 未结 4 1209
情歌与酒
情歌与酒 2021-02-05 23:32

In a Java threaddump I found the following:

\"TP-Processor184\" daemon prio=10 tid=0x00007f2a7c056800 nid=0x47e7 waiting for monitor entry [0x00007f2a21278000]
          


        
4条回答
  •  隐瞒了意图╮
    2021-02-05 23:40

    When a thread locks an object but wait()s another thread can lock the same object. You should be able to see a number of threads "holding" the same lock all waiting.

    AFAIK, the only other occasion is when multiple threads have locked and waited and are ready to re-acquire the the lock e.g. on a notifyAll(). They are not waiting any more but cannot continue until they have obtained the lock again. (only one thread at a time time can do this)

提交回复
热议问题