How to detect thread being blocked by IO?

后端 未结 2 589
隐瞒了意图╮
隐瞒了意图╮ 2021-02-03 12:13

In Java, thread can have different state:

NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, TERMINATED

However, when the thread is blocked by IO, its state is \"RU

2条回答
  •  伪装坚强ぢ
    2021-02-03 12:38

    You can check the statckTraces of the thread then find if the last stack is in some specific method associated with i/o blocking (eg: java.net.SocketInputStream.socketRead0)

    This is not a clever way but it works.

    JProfiler supports the feature you need, details show at: WHAT'S NEW IN JPROFILER 3.1

提交回复
热议问题