com.sun.messaging.jmq.jmsserver.service.HAMonitorService类包含HATimerThread,它启动一个HATimerThread,然后运行它(HATimerThread是一个可运行的)。
此线程不是deamon线程。
运行代码如下;
public void run() {
while (true) {
long time = System.currentTimeMillis();
synchronized(this) {
if (time < nexttime) {
try {
this.wait(nexttime - time);
} catch (InterruptedException ex) {}
continue;
} else {
child.run();
}
}
if (repeatItr == 0) break;
time = System.currentTimeMillis();
long tmpnext = nexttime + repeatItr;
if (time >= tmpnext) {
nexttime = time;
} else {
nexttime = tmpnext;
}
}
}这个线程可以退出的唯一方法是如果repeatItr == 0。但是,一旦在构造函数中设置(HAMonitorService的构造函数调用它,使其为非0),任何事情似乎都不会改变它。这意味着循环永远不会退出,这意味着线程永远不会停止,而且由于它不是守护进程线程,所以VM永远不会关闭。
这是否一个错误,还是有其他机制阻止它,而我没有想过?目前,运行我的嵌入式集群代理的进程从未因此而退出,尽管它的其余部分完全关闭.
尝试使用4.5.2和5.1。
我为5.1重新构建了源代码,将HATimerThread创建的线程设置为deamon,现在一切正常。
发布于 2014-11-19 09:17:00
据甲骨文的康艾米说
“只要代理不终止,或者util代理调用System.exit()来终止或重新启动自己,HAMonitorService中的System.exit就应该运行。但是它可以是守护进程线程。”
请参阅OpenMq用户论坛
https://stackoverflow.com/questions/26999376
复制相似问题