是不是因为程序里的异常没有捕获????
解决方案 »
- java程序实现将wmf格式图片转换为jpg格式的
- 开贴聊,下个周一就要求上班了,可以没有一点兴奋,求java前辈指教。
- struts2自定义拦截器中返回错误信息的问题!
- 使用ajax提交action,后台返回一个list,list在本页面显示的源码。不刷新页面。
- jbpm3.2和spring aop行为日志切面的兼容问题
- JSF的faces-config.xml支持分模块吗?.......
- struts中如何避免重复刷新
- Jboss中配多个域名对多个目录
- linux 下 jbuilderx 的问题。。。
- 关于使用struts的系统架构问题.
- java中的添加背景图片
- ■■跪求■■JAVA实现 CRC16■。已经有C 和 C#版本了。仅做成JAVA版本即可
public class AutoMatic {
static Logger logger = Logger.getLogger ( AutoMatic.class.getName () ) ;
//程序启动一分钟后开始统计
static long timerDelay = 1000 * 60 * 1L;
//间隔时间,每2小时插一次
static long timerPeriod = 1000 * 60 * 60 *2L;
// {
// try{
// new Timer().schedule(new AutoMaticTimerTask(), timerDelay, timerPeriod);//timerDelay从现在开始延迟执行的时间 timerPeriod 延迟参数的时间单位
// System.out.println("服务已启动.服务启动一分钟后开始进行读取数据.");
// }catch (Exception e) {
// System.err.println("服务启动失败.");
// logger.error("#ERROR# :服务启动失败!", e);
// }
// }
class AutoMaticTimerTask extends TimerTask{
public void run(){
System.out.println("开始读取数据!");
try {
new ReportMinperiodService().selectBeforeTime();
ReportMinperiodService.ANALYSE_LOCKED=false;
System.out.println("ReportMinperiodService----->插值结束!!");
new ReportDayService().selectBeforeTime();
ReportDayService.ANALYSE_LOCKED=false;
System.out.println("ReportDayService----->插值结束!!");
new ReportMonthService().selectBeforeTime();
ReportMonthService.ANALYSE_LOCKED=false;
System.out.println("ReportMonthService----->插值结束!!");
new WrReportMinperiodService().selectBeforeTime();
WrReportMinperiodService.ANALYSE_LOCKED=false;
System.out.println("WrReportMinperiodService------>插值结束");
new WrReportDayService().selectBeforeTime();
WrReportDayService.ANALYSE_LOCKED=false;
System.out.println("WrReportDayService------>插值结束");
new WrReportMonthService().selectBeforeTime();
WrReportMonthService.ANALYSE_LOCKED=false;
System.out.println("WrReportMonthService------>插值结束");
new JzqEmsBaseService().selectBeforeTime();
JzqEmsBaseService.ANALYSE_LOCKED=false;
System.out.println("JzqEmsBaseService------>插值结束!!");
new JzqMidOutputService().selectBeforeTime();
JzqMidOutputService.ANALYSE_LOCKED=false;
System.out.println("JzqMidOutputService------>插值结束!!");
} catch (Exception e) {
e.printStackTrace();
logger.error("#ERROR# :插入错误!", e);
}
}
}
public static void main(String[] args) {
try{
new Timer().schedule(new AutoMatic().new AutoMaticTimerTask(), timerDelay, timerPeriod);//timerDelay从现在开始延迟执行的时间 timerPeriod 延迟参数的时间单位
System.out.println("服务已启动.一分钟后开始进行读取数据.");
}catch (Exception e) {
System.err.println("服务启动失败.");
logger.error("#ERROR# :服务启动失败!", e);
}
}
}
没用tomcat 直接在服务器上执行的!!
如果是服务器停了的话,排除其他问题的可能性的话,就是定时器代码中有消耗资源的代码导致内存不足挂掉了!
如果是定时器停了的话,就要靠看是一开始就不能正常的运行定时器代码,
还是运行了一段时间过后在某次执行的时候出错导致服务崩溃。
建议debug调试,肯定能发现问题
写了个死循环 让他执行一段时间 sleep一下 就没有这种问题了