contextInitialized和contextDestroyed的问题?

asxdui 2006-09-08 09:49:37

我现在用的开发工具是wsad,开发中遇到如下情况:
public class XmlListion extends HttpServlet implements ServletContextListener {

/* (非 Javadoc)
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
public void contextInitialized(ServletContextEvent arg0) {
// TODO 自动生成方法存根
System.out.println("test============contextInitialized");

sleepTime = configInfo.getPropertiesValue("parameter","SleepTime");
rt = new XmlTimer(Integer.parseInt(sleepTime));
rt.start();
}

/* (非 Javadoc)
* @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
*/
public void contextDestroyed(ServletContextEvent arg0) {
// TODO 自动生成方法存根
System.out.println("test============contextDestroyed");
if (rt != null) {
rt.stop();
}
}

}
在网上看过很多文章说,contextInitialized和contextDestroyed是根据服务的启动而启动或者关闭的,但是实际上我在用websphere重新发布一个版本时,有时候会出现上面的代码中调用的定时器会没有关闭,而且这个进程会出现耗用99。99%的cpu以至于服务会死掉,请问大家有什么好的方法能不能帮帮我,多谢了!
...全文
969 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tcmis 2006-09-08
  • 打赏
  • 举报
回复
学习

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧