简单用法
public class TestTask { /** * 定时任务执行器 */ private ScheduledExecutorService executorService; /** * 定时任务间隔时间 */ private long taskTime; public TestTask(int threadSize, long taskTime) { this.beatTaskTime = beatTaskTime; executorService = new ScheduledThreadPoolExecutor(threadSize, (r) -> { Thread thread = new Thread(r); thread.setDaemon(true); thread.setName("com.wmang.service.test"); return thread; }); } public void initBeatTask() { executorService.scheduleAtFixedRate(() -> { // 定时任务执行逻辑 }, beatTaskTime,beatTaskTime, TimeUnit.MILLISECONDS); } }schedule(Runnable command, long delay, TimeUnit un