HOW TO FIND DIED LOOP

    @Test
    public void testLoop() {
        int i = 1;
        while (i == 1) {
            System.out.println(System.currentTimeMillis());
        }
    }
zeal@zeal-pc:~$ jps -mlvV
6641 com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.loop.Test,testLoop -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:39892,suspend=y,server=n -ea -Didea.junit.sm_runner -Dfile.encoding=UTF-8

zeal@zeal-pc:~$ top -Hp 6641
top - 10:02:09 up 2 days, 0 min,  1 user,  load average: 3.52, 1.70, 0.90
Threads:  17 total,   1 running,  16 sleeping,   0 stopped,   0 zombie
%Cpu(s): 77.8 us, 13.2 sy,  0.0 ni,  7.6 id,  1.0 wa,  0.0 hi,  0.3 si,  0.0 st
KiB Mem :  7736328 total,   125432 free,  6524184 used,  1086712 buff/cache
KiB Swap:  3905532 total,  1087280 free,  2818252 used.   527408 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                                                                                              
 6642 zeal      20   0 3292308 278388   1884 R 74.3  3.6   0:48.55 java                                                                                                                                                                 
 6646 zeal      20   0 3292308 278388   1884 S  0.3  3.6   0:00.08 java                                                                                                                                                                 
 6641 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6643 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.07 java                                                                                                                                                                 
 6645 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.07 java                                                                                                                                                                 
 6647 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.09 java                                                                                                                                                                 
 6654 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.01 java                                                                                                                                                                 
 6655 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6657 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6664 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6665 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6668 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6669 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6670 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.32 java                                                                                                                                                                 
 6671 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.40 java                                                                                                                                                                 
 6672 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.00 java                                                                                                                                                                 
 6673 zeal      20   0 3292308 278388   1884 S  0.0  3.6   0:00.02 java       

CPU 占用最高的线程id 6642 转为16进制 19F2

zeal@zeal-pc:~$ jstack -l 6641
2017-05-17 10:03:59
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode):

"Attach Listener" daemon prio=10 tid=0x00007fd690001000 nid=0x1ad8 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Service Thread" daemon prio=10 tid=0x00007fd6c00b1000 nid=0x1a10 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"C2 CompilerThread1" daemon prio=10 tid=0x00007fd6c00ae800 nid=0x1a0f waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"C2 CompilerThread0" daemon prio=10 tid=0x00007fd6c00ac000 nid=0x1a0e waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"JDWP Command Reader" daemon prio=10 tid=0x00007fd694001000 nid=0x1a0d runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"JDWP Event Helper Thread" daemon prio=10 tid=0x00007fd6c00a9800 nid=0x1a0c runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"JDWP Transport Listener: dt_socket" daemon prio=10 tid=0x00007fd6c00a6000 nid=0x1a09 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Signal Dispatcher" daemon prio=10 tid=0x00007fd6c0090000 nid=0x1a08 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Finalizer" daemon prio=10 tid=0x00007fd6c0078800 nid=0x1a01 in Object.wait() [0x00007fd6aadcc000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0000000089e045e8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x0000000089e045e8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

   Locked ownable synchronizers:
    - None

"Reference Handler" daemon prio=10 tid=0x00007fd6c0076800 nid=0x19ff in Object.wait() [0x00007fd6aaecd000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0000000089e06858> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x0000000089e06858> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
    - None

"main" prio=10 tid=0x00007fd6c0012800 nid=0x19f2 runnable [0x00007fd6c75aa000]
   java.lang.Thread.State: RUNNABLE
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:345)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    - locked <0x0000000089e4f040> (a java.io.BufferedOutputStream)
    at java.io.PrintStream.write(PrintStream.java:482)
    - locked <0x0000000089e06990> (a java.io.PrintStream)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
    at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
    - locked <0x0000000089e06920> (a java.io.OutputStreamWriter)
    at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
    at java.io.PrintStream.write(PrintStream.java:527)
    - locked <0x0000000089e06990> (a java.io.PrintStream)
    at java.io.PrintStream.print(PrintStream.java:611)
    at java.io.PrintStream.println(PrintStream.java:750)
    - locked <0x0000000089e06990> (a java.io.PrintStream)
    at com.loop.Test.testLoop(Test.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)

   Locked ownable synchronizers:
    - None

"VM Thread" prio=10 tid=0x00007fd6c0072000 nid=0x19fe runnable 

"GC task thread#0 (ParallelGC)" prio=10 tid=0x00007fd6c0028000 nid=0x19f3 runnable 

"GC task thread#1 (ParallelGC)" prio=10 tid=0x00007fd6c002a000 nid=0x19f5 runnable 

"GC task thread#2 (ParallelGC)" prio=10 tid=0x00007fd6c002b800 nid=0x19f6 runnable 

"GC task thread#3 (ParallelGC)" prio=10 tid=0x00007fd6c002d800 nid=0x19f7 runnable 

"VM Periodic Task Thread" prio=10 tid=0x00007fd6c00b4000 nid=0x1a11 waiting on condition 

JNI global references: 2440

找到19F2 nid=0x19f2 at com.loop.Test.testLoop(Test.java:21)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,937评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,503评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,712评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,668评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,677评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,601评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,975评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,637评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,881评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,621评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,710评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,387评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,971评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,947评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,189评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,805评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,449评论 2 342

推荐阅读更多精彩内容