我在哪里开始调查我的Java进程不会结束? [英] Where do I start investigating my Java process that won't end?
本文介绍了我在哪里开始调查我的Java进程不会结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Unsafe.park(boolean,long)
。如何/我应该在哪里开始调查? 第二个线程的简化堆栈跟踪是:
Unsafe.park(boolean,long)
在LockSupport.park(Object)
在AbstractQueuedSynchronizer $ ConditionObject.await()
在LinkedBlockingQueue< E> .take )
在ThreadPoolExecutor.getTask()
在ThreadPoolExecutor $ Worker.run()
在Thread.run()
解决方案
您需要执行以下两项操作才能终止您的 ExecutorService
线程: / p>
- 指定一个
a href =http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/util/concurrent/ThreadFactoryBuilder.html =nofollow noreferrer> ThreadFactoryBuilder
类来自 Guava 将使这更容易。) - 致电
shutdown()
在您的ExecutorService
在main
方法的末尾。)
I have a Java application which doesn't end. The main method finishes, but threads remain active and the application doesn't end. The thing is, there don't appear to be any monitor locks / waits, so I can't see why it's not ending. According to Eclipse, I am left with two non-Daemon threads. One is labelled [DestroyJavaVM] (looks hopeful!) and the other seems to be blocked in Unsafe.park(boolean, long)
. How / where should I start investigating this?
The abridged stacktrace of the second thread is:
Unsafe.park(boolean, long)
at LockSupport.park(Object)
at AbstractQueuedSynchronizer$ConditionObject.await()
at LinkedBlockingQueue<E>.take()
at ThreadPoolExecutor.getTask()
at ThreadPoolExecutor$Worker.run()
at Thread.run()
解决方案
You need to do one of two things to terminate your ExecutorService
thread:
- Specify a
ThreadFactory
that creates daemon threads (theThreadFactoryBuilder
class from Guava will make this easier.) - Call
shutdown()
on yourExecutorService
as part of the application shutdown (e.g. at the end of yourmain
method.)
这篇关于我在哪里开始调查我的Java进程不会结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文