在我自己的剖析器上工作,我想解释一下我所看到的.即使在最简单的程序中,也会出现一些默认线程:
虽然他们的名字非常自我记录,但我希望获得更多信息.似乎这些线程没有记录,有人知道挖掘这些信息的来源,甚至知道这些线程到底做了什么吗?
以下简单的Java代码:
public class Main {
public static void main(String[] args) throws InterruptedException {
System.out.println("Start");
Thread.sleep(5000);
System.out.println("Done");
}
}
Run Code Online (Sandbox Code Playgroud)
运行使用14个线程.我知道有些GC线程在后台运行,但其他的是什么?为什么有那么多线程?我在Java 1.6.0_26上使用Gentoo Linux.使用Eclipse的编译器或javac进行编译并没有什么区别(在Eclipse中以调试模式运行它会增加3个线程,但这可能是合理的).
我不知道我的java进程发生了什么.此过程是索引过程.它从一组zip文件中读取文档,并将它们添加到lucene索引中.GC日志显示它正在连续运行Full GC.
4959.569: [Full GC 19960K->19960K(10617856K), 0.1648590 secs]
4959.764: [Full GC 19960K->19960K(10617856K), 0.1650240 secs]
4959.959: [Full GC 19960K->19960K(10617856K), 0.1649380 secs]
4960.154: [Full GC 19960K->19960K(10617856K), 0.1650000 secs]
4960.350: [Full GC 19960K->19960K(10617856K), 0.1648900 secs]
Run Code Online (Sandbox Code Playgroud)
至于我可以解释这些线条,前后对象的大小大约是19M,但为什么它一直在运行呢?
线程转储如下所示:
........[Unloading class sun.reflect.GeneratedConstructorAccessor1]
[Unloading class sun.reflect.GeneratedConstructorAccessor2]
[Unloading class sun.reflect.GeneratedConstructorAccessor3]
2012-01-13 12:55:24
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.4-b02 mixed mode):
"org.cxv.CXVIndexer.main()" prio=10 tid=0x00007f4540474000 nid=0x4b15 waiting on condition [0x00007f453f5ed000]
java.lang.Thread.State: RUNNABLE
at org.apache.lucene.index.DocFieldProcessorPerThread.abort(DocFieldProcessorPerThread.java:72)
at org.apache.lucene.index.DocumentsWriter.abort(DocumentsWriter.java:424)
- locked <0x000000034ab44fb8> (a org.apache.lucene.index.DocumentsWriter)
at org.apache.lucene.index.DocumentsWriter.flush(DocumentsWriter.java:659)
- locked <0x000000034ab44fb8> …Run Code Online (Sandbox Code Playgroud)