Class TerminableRunnable

  • All Implemented Interfaces:
    java.lang.Runnable
    Direct Known Subclasses:
    FailoverLoop

    public abstract class TerminableRunnable
    extends java.lang.Object
    implements java.lang.Runnable
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  TerminableRunnable.State  
    • Constructor Summary

      Constructors 
      Constructor Description
      TerminableRunnable​(java.util.concurrent.ScheduledExecutorService scheduler, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void blockTillTerminated()
      Unschedule next launched, and wait for the current task to complete before closing it.
      protected abstract void doRun()  
      boolean isUnschedule()  
      void run()  
      void unscheduleTask()
      Unschedule task if active, and cancel thread to inform it must be interrupted in a proper way.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • unschedule

        private final java.util.concurrent.atomic.AtomicBoolean unschedule
      • scheduledFuture

        private volatile java.util.concurrent.ScheduledFuture<?> scheduledFuture
    • Constructor Detail

      • TerminableRunnable

        public TerminableRunnable​(java.util.concurrent.ScheduledExecutorService scheduler,
                                  long initialDelay,
                                  long delay,
                                  java.util.concurrent.TimeUnit unit)
    • Method Detail

      • doRun

        protected abstract void doRun()
      • run

        public final void run()
        Specified by:
        run in interface java.lang.Runnable
      • blockTillTerminated

        public void blockTillTerminated()
        Unschedule next launched, and wait for the current task to complete before closing it.
      • isUnschedule

        public boolean isUnschedule()
      • unscheduleTask

        public void unscheduleTask()
        Unschedule task if active, and cancel thread to inform it must be interrupted in a proper way.