保险业网站建设,懂做网站怎么赚钱,wordpress 动图,惠州网站建设报价你可能应该在一个while(true)循环中包含try块,因为如果第一次运行没有抛出异常,你将退出你的方法,如果第二次调用抛出一个,你将无法捕获它.我还会在自己的线程中运行递归调用,以避免在事情变坏时出现StackOverFlow错误的风险.所以它看起来像这样#xff1a;private void start…你可能应该在一个while(true)循环中包含try块,因为如果第一次运行没有抛出异常,你将退出你的方法,如果第二次调用抛出一个,你将无法捕获它.我还会在自己的线程中运行递归调用,以避免在事情变坏时出现StackOverFlow错误的风险.所以它看起来像这样private void startMemoryUpdateSchedule(final ScheduledExecutorService service) {final ScheduledFuture future service.scheduleWithFixedDelay(new MemoryUpdateThread(), 1, UPDATE_MEMORY_SCHEDULE, TimeUnit.MINUTES);Runnable watchdog new Runnable() {Overridepublic void run() {while (true) {try {future.get();} catch (ExecutionException e) {//handle itstartMemoryUpdateSchedule(service);return;} catch (InterruptedException e) {//handle itreturn;}}}};new Thread(watchdog).start();}