@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)
网友评论