Class TaskScheduler<T>


  • public class TaskScheduler<T>
    extends java.lang.Object
    Author:
    Loc Ha
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TaskScheduler.Task<T>  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean cancelMayInterruptIfRunning  
      protected java.util.concurrent.ScheduledExecutorService executor  
      protected java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ScheduledFuture<?>> taskRef  
    • Constructor Summary

      Constructors 
      Constructor Description
      TaskScheduler()  
      TaskScheduler​(boolean cancelMayInterruptIfRunning)  
      TaskScheduler​(boolean cancelMayInterruptIfRunning, java.util.concurrent.ScheduledExecutorService executor)  
      TaskScheduler​(boolean cancelMayInterruptIfRunning, java.util.concurrent.ThreadFactory threadFactory)  
    • Field Detail

      • cancelMayInterruptIfRunning

        protected final boolean cancelMayInterruptIfRunning
      • executor

        protected final java.util.concurrent.ScheduledExecutorService executor
      • taskRef

        protected final java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ScheduledFuture<?>> taskRef
    • Constructor Detail

      • TaskScheduler

        public TaskScheduler()
      • TaskScheduler

        public TaskScheduler​(boolean cancelMayInterruptIfRunning)
      • TaskScheduler

        public TaskScheduler​(boolean cancelMayInterruptIfRunning,
                             java.util.concurrent.ThreadFactory threadFactory)
      • TaskScheduler

        public TaskScheduler​(boolean cancelMayInterruptIfRunning,
                             java.util.concurrent.ScheduledExecutorService executor)
    • Method Detail

      • scheduleAtFixedRate

        public void scheduleAtFixedRate​(TaskScheduler.Task<T> task,
                                        long initialDelay,
                                        long period,
                                        java.util.concurrent.TimeUnit unit)
      • scheduleWithFixedDelay

        public void scheduleWithFixedDelay​(TaskScheduler.Task<T> task,
                                           long initialDelay,
                                           long delay,
                                           java.util.concurrent.TimeUnit unit)
      • cancel

        public void cancel()
      • shutdownNow

        public void shutdownNow()
      • hasTask

        public boolean hasTask()