我想写一个Timer,功能是每隔几秒扫描数据库进行一定的处理,但TimerTask为什么发生错误(比如,SQL异常,数据库连接异常,或调用Tuxedo服务异常)后,为什么不再描扫,按理说,这是一个定时器,不管程序中发错什么异常,只要我try catch了,这次扫描失败,不影响下次呀?下次也应该继续扫描呀?为什么只要发生异常,Timer就不再扫描
private static ScheduledExecutorService executor = null;
executor = new ScheduledThreadPoolExecutor(1);
executor.scheduleWithFixedDelay(new WeatherMonitor(), 0, 60*60,
TimeUnit.SECONDS);
猜你喜欢
本站原创《复杂软件设计之道:领域驱动设计全面解析与实战》