Class Timer.Task

  • All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    Timer

    public abstract static class Timer.Task
    extends java.lang.Object
    implements java.lang.Runnable
    Runnable that can be scheduled on a Timer.
    • Constructor Summary

      Constructors 
      Constructor Description
      Task()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      Cancels the task.
      long getExecuteTimeMillis()
      Returns the time in milliseconds when this task will be executed next.
      boolean isScheduled()
      Returns true if this task is scheduled to be executed in the future by a timer.
      abstract void run()
      If this is the last time the task will be ran or the task is first cancelled, it may be scheduled again in this method.
      • Methods inherited from class java.lang.Object

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

      • Task

        public Task()
    • Method Detail

      • run

        public abstract void run()
        If this is the last time the task will be ran or the task is first cancelled, it may be scheduled again in this method.
        Specified by:
        run in interface java.lang.Runnable
      • cancel

        public void cancel()
        Cancels the task. It will not be executed until it is scheduled again. This method can be called at any time.
      • isScheduled

        public boolean isScheduled()
        Returns true if this task is scheduled to be executed in the future by a timer. The execution time may be reached at any time after calling this method, which may change the scheduled state. To prevent the scheduled state from changing, synchronize on this task object, eg:
         synchronized (task) {
                if (!task.isScheduled()) { ... }
         }
         
      • getExecuteTimeMillis

        public long getExecuteTimeMillis()
        Returns the time in milliseconds when this task will be executed next.