1
我可以在我的遗留应用程序中看到下面的代码。一旦我运行main
方法,我发现这个线程永远运行。 但是在调试时,为什么线程永远运行?这个线程如何在Spring中继续运行?
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MyClass {
public static void main(String[] args) {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(ResourcesFactoryApplicationContext.getInstance());
applicationContext.registerShutdownHook();
applicationContext.setAllowBeanDefinitionOverriding(false);
applicationContext.setConfigLocation("configFileName");
applicationContext.refresh();
}
}
有人谁知道更多关于Spring比我也许能回答这个问题的时候了,所以这可能是一个愚蠢的请求,但是你可以张贴在调试器显示正在运行的线程的堆栈跟踪? –
您确定所讨论的线程是使用'main()'的线程,而不是其中一个Spring bean启动的其他线程吗? – axtavt
如果不是deamon线程,每个线程将永远运行。 – robermann