编辑:
我现在确定问题与此有关
????while(true)循环保存所有其他命令,因为我已将其注释掉,并且应用程序在没有附加异常的情况下进行部署.我不确定它有多重要,但我的ServletContextListener实现如下所示:
?????????公共类BidPushService实现ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
//Some init code not relevant, omitted for clarity
BidPushThread t= new BidPushThread();
t.setServletContext(sce.getServletContext());
t.run();
}
所以现在线程在部署应用程序时运行但由于while循环被注释它没有任何实际意义.
当我的应用程序加载时,我需要在后台运行一个线程,并且不断(没有超时)检查某个队列中的对象.当然,一旦有了对象,它就“照顾它们”,然后继续检查队列.
目前,我正在实现ServletContextListener接口,并在应用程序加载时调用.在其中,我做了一些维护工作并启动了一个我从java.lang.Thread继承的线程.
这是我的问题开始的地方(或者我认为).在我的run()方法中,我有一个
while (true) {
//some code which doesn't put the thread to sleep ever
}
当我尝试将我的应用程序部署到服务器时,我得到一个java.util.concurrent.TimeOutException.
我究竟做错了什么&