Class DynamicTask

java.lang.Object
io.github.lunasaw.sip.common.utils.DynamicTask

@Component public class DynamicTask extends Object
动态定时任务
Author:
lin
  • Constructor Details

    • DynamicTask

      public DynamicTask()
  • Method Details

    • DynamicTask

      @PostConstruct public void DynamicTask()
    • startCron

      public void startCron(String key, Runnable task, Integer duration, TimeUnit timeUnit)
    • startCron

      public void startCron(String key, Runnable task, long time)
      循环执行的任务
      Parameters:
      key - 任务ID
      task - 任务
      time - 间隔 毫秒
    • startDelay

      public void startDelay(String key, Runnable task, int delay)
      延时任务
      Parameters:
      key - 任务ID
      task - 任务
      delay - 延时 /毫秒
    • stop

      public boolean stop(String key)
    • contains

      public boolean contains(String key)
    • getAllKeys

      public Set<String> getAllKeys()
    • get

      public Runnable get(String key)
    • execute

      @Scheduled(cron="0 0/5 * * * ?") public void execute()
      每五分钟检查失效的任务,并移除
    • isAlive

      public boolean isAlive(String key)