Java线程挂起没有死锁

时间:2014-06-09 19:05:25

标签: java multithreading process freeze hang

我目前在处理暂停的过程中遇到了一些问题。

首先,下面的线程转储显示没有死锁。另一个有趣的事情是,该过程悬挂在java.lang.System.identityHashCode方法上。该进程当前的CPU使用率为0%,有时高峰为1%...通常该进程使用100%。它使用1.7GB的RAM(这个过程是正常的)。该机器有足够的CPU,磁盘空间和RAM。

Attaching to process ID 4146, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 23.7-b01
Deadlock Detection:

No deadlocks found.

Thread 12761: (state = BLOCKED)


Thread 4159: (state = BLOCKED)


Thread 4158: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
 - java.lang.ref.ReferenceQueue.remove(long) @bci=44, line=135 (Interpreted frame)
 - java.lang.ref.ReferenceQueue.remove() @bci=2, line=151 (Interpreted frame)
 - java.lang.ref.Finalizer$FinalizerThread.run() @bci=3, line=177 (Interpreted frame)


Thread 4157: (state = BLOCKED)
 - java.lang.Object.wait(long) @bci=0 (Interpreted frame)
 - java.lang.Object.wait() @bci=2, line=503 (Interpreted frame)
 - java.lang.ref.Reference$ReferenceHandler.run() @bci=46, line=133 (Interpreted frame)


Thread 4147: (state = IN_VM)
 - java.lang.System.identityHashCode(java.lang.Object) @bci=0 (Compiled frame; information may be imprecise)
 - java.util.IdentityHashMap.hash(java.lang.Object, int) @bci=1, line=301 (Compiled frame)
 - java.util.IdentityHashMap.containsKey(java.lang.Object) @bci=17, line=358 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=18, line=346 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.FastClonerArrayList.clone(java.lang.Object, com.rits.cloning.Cloner, java.util.Map) @bci=47, line=23 (Compiled frame)
 - com.rits.cloning.Cloner.fastClone(java.lang.Object, java.util.Map) @bci=30, line=96 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=100, line=355 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.FastClonerArrayList.clone(java.lang.Object, com.rits.cloning.Cloner, java.util.Map) @bci=47, line=23 (Compiled frame)
 - com.rits.cloning.Cloner.fastClone(java.lang.Object, java.util.Map) @bci=30, line=96 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=100, line=355 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.FastClonerArrayList.clone(java.lang.Object, com.rits.cloning.Cloner, java.util.Map) @bci=47, line=23 (Compiled frame)
 - com.rits.cloning.Cloner.fastClone(java.lang.Object, java.util.Map) @bci=30, line=96 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=100, line=355 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.FastClonerArrayList.clone(java.lang.Object, com.rits.cloning.Cloner, java.util.Map) @bci=47, line=23 (Compiled frame)
 - com.rits.cloning.Cloner.fastClone(java.lang.Object, java.util.Map) @bci=30, line=96 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=100, line=355 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.FastClonerArrayList.clone(java.lang.Object, com.rits.cloning.Cloner, java.util.Map) @bci=47, line=23 (Compiled frame)
 - com.rits.cloning.Cloner.fastClone(java.lang.Object, java.util.Map) @bci=30, line=96 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=100, line=355 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.cloneInternal(java.lang.Object, java.util.Map) @bci=368, line=404 (Compiled frame)
 - com.rits.cloning.Cloner.deepClone(java.lang.Object) @bci=61, line=309 (Compiled frame)
 - arquitetura.representation.Architecture.deepClone() @bci=23, line=497 (Compiled frame)
 - jmetal.operators.mutation.PLAFeatureMutation.execute(java.lang.Object) @bci=109, line=862 (Compiled frame)
 - jmetal.metaheuristics.nsgaII.NSGAII.execute() @bci=321, line=129 (Compiled frame)
 - br.ufpr.inf.opla.patterns.main.NSGAII_OPLA.main(java.lang.String[]) @bci=1116, line=179 (Interpreted frame)

我正在使用不同的参数执行相同的过程一段时间(超过一周)。我正在使用进化算法,所以耗费时间对我的问题来说是正常的。我执行了120次相同的进程(使用不同的参数),这个是第一个挂起的时间。目前有4个进程同时运行(计算被吊死的进程),有些甚至更多的进程需要花费更多时间。他们正在完成,我的程序通常使用ProcessBuilder启动其他进程。我确实阅读了每一个的输出。被绞死的过程在不到一半的时间内输出正常的日志。没有错误。另一个重要的事情是,进程被冻结的方法不会产生输出,因此我假设输出消耗没有问题。

我的问题是:我不想杀死这个过程,所以有没有办法unhang这个过程?另外,为什么它处于IN_VM状态(在VirtualMachine中运行)并且仍然被冻结?进程以java.lang.System.identityHashCode方法冻结是否正常?为什么我的CPU使用0%(极少1%)?

如果我可以提供任何其他信息,请发出询问,我很乐意在此发布。

提前致谢。

编辑:虽然我使用多线程,但每个线程使用Process启动ProcessBuilder对象。因此,挂起进程是一个独立的JVM实例,只执行一个主线程。我将输出重定向到一个文件,但如前所述,该进程挂起了一个不产生输出的方法,因此我假设输出消耗没有问题。

EDIT2:杀死了这个过程。后续流程已经开始并且运行顺利。

1 个答案:

答案 0 :(得分:0)

这个过程并没有停止,你只是碰巧在上面发布的状态中发现了它。你可以告诉,因为有问题的线程并没有像其他人那样说BLOCKED,所以它正常执行。

为什么进程不再执行可能有不同的原因,但我可以向您保证,它们都不与identityHashCode相关联,因为这是一个经过良好测试的内部Java函数。

继续:

  • 比较几个挂断的JVM状态。如果它始终与上面相同,则问题可能与哈希生成相关联。如果不是:

  • 发布更相关的代码,以便我们查看。如果问题不在这行代码中,那么它必须在其他地方(com.rits.cloning.Cloner听起来像是开始寻找的合理点)。

  • 告诉我们您要归档的内容,有人可能会发现错误或更好的方法,这完全可以避免导致问题的原因。