Getting the Java thread id and stack trace of run-away Java thread

前端 未结 5 783
有刺的猬
有刺的猬 2020-12-14 09:19

On my busiest production installation, on occasion I get a single thread that seems to get stuck in an infinite loop. I\'ve not managed to figure out who is the culprit, af

5条回答
  •  自闭症患者
    2020-12-14 10:18

    From memory if you CTRL-BREAK on the console you will get a dump of the current threads and a few of their stack trace frames.

    From memory (I'm not sure if this is an IntelliJ IDEa feature, or it is default in java) but it will tell you which thread is deadlocked, and which object they are waiting on. You should be able to redirect the output to a file, and just grep for the DEADLOCKED text.

    JConsole, VisualVM or other profilers such as JProfiler will also show you the threads and their stacks, however if you don't want to use any external tool I think CTRL-BREAK will give you what you're looking for.

提交回复
热议问题