Java根据间隔多少时间后,执行业务功能

public static ThreadFactory threadFactoryName = new ThreadFactoryBuilder()
            .setNameFormat("push-leave-learning-pool-%d").build();
    ScheduledThreadPoolExecutor scheduledExecutorService = new ScheduledThreadPoolExecutor(1, threadFactoryName);

    //TODO  继续计时,也需要调用
    public void schedeledTask(LearnContentDO contentDO, Long seconds) {
        scheduledExecutorService.schedule(() -> learnPush(contentDO.getUserId(), contentDO.getId()), seconds, TimeUnit.SECONDS);
    }

你可能感兴趣的:(java)