我自己解决了这个问题。与其他答案相反,我不建议发出该t.stop()
命令。此方法已被弃用,这是有充分理由的。请参考Oracle这样做的原因。
但是,有一种解决方案可以消除此错误,而无需诉诸t.stop()
…
您可以使用提供的大多数代码@Oso,只需替换以下部分
Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
for(Thread t:threadArray) {
if(t.getName().contains("Abandoned connection cleanup thread")) {
synchronized(t) {
t.stop(); //don't complain, it works
}
}
}
try {
AbandonedConnectionCleanupThread.shutdown();
} catch (InterruptedException e) {
logger.warn("SEVERE problem cleaning up: " + e.getMessage());
e.printStackTrace();
}