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

前端 未结 5 785
有刺的猬
有刺的猬 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:13

    It looks like the nid in the jstack output is the Linux LWP id.

    "http-342.877.573.944-8080-360" daemon prio=10 tid=0x0000002adaba9c00 nid=0x754c in Object.wait() [0x00000000595bc000..0x00000000595bccb0]
    

    Convert the nid to decimal and you have the LWP id. In your case 0x754c is 30028. This process is not shown in our ps output, but it was probably one of the LWPs you have omitted to save space.

    Here's a little a Perl snippet you can use to pipe the output of jstack to:

    #!/usr/bin/perl -w
    while (<>) {
        if (/nid=(0x[[:xdigit:]]+)/) {
            $lwp = hex($1);
            s/nid=/lwp=$lwp nid=/;
        }
        print;
    }
    

提交回复
热议问题