001package io.jboot.components.schedule; 002 003import com.jfinal.log.Log; 004 005/** 006 * 使用 try catch 包裹业务代码,防止业务现场抛出异常导致 ScheduledThreadPoolExecutor 终止调度 007 * 008 * @author orangej 009 * @since 2021-9-26 010 */ 011public class JbootSafeRunnable implements Runnable { 012 private static final Log LOG = Log.getLog(JbootSafeRunnable.class); 013 014 private Runnable job; 015 016 public JbootSafeRunnable(Runnable job) { 017 this.job = job; 018 } 019 020 @Override 021 public void run() { 022 try { 023 job.run(); 024 } catch (Throwable ex) { 025 LOG.error(ex.toString(), ex); 026 } 027 } 028}