类 ScheduledTimerListener

    • 构造器详细资料

      • ScheduledTimerListener

        public ScheduledTimerListener​(TimerListener timerListener)
        Create a new ScheduledTimerListener, with default one-time execution without delay.
        参数:
        timerListener - the TimerListener to schedule
      • ScheduledTimerListener

        public ScheduledTimerListener​(TimerListener timerListener,
                                      long delay)
        Create a new ScheduledTimerListener, with default one-time execution with the given delay.
        参数:
        timerListener - the TimerListener to schedule
        delay - the delay before starting the task for the first time (ms)
      • ScheduledTimerListener

        public ScheduledTimerListener​(TimerListener timerListener,
                                      long delay,
                                      long period,
                                      boolean fixedRate)
        Create a new ScheduledTimerListener.
        参数:
        timerListener - the TimerListener to schedule
        delay - the delay before starting the task for the first time (ms)
        period - the period between repeated task executions (ms)
        fixedRate - whether to schedule as fixed-rate execution
      • ScheduledTimerListener

        public ScheduledTimerListener​(Runnable timerTask)
        Create a new ScheduledTimerListener, with default one-time execution without delay.
        参数:
        timerTask - the Runnable to schedule as TimerListener
      • ScheduledTimerListener

        public ScheduledTimerListener​(Runnable timerTask,
                                      long delay)
        Create a new ScheduledTimerListener, with default one-time execution with the given delay.
        参数:
        timerTask - the Runnable to schedule as TimerListener
        delay - the delay before starting the task for the first time (ms)
      • ScheduledTimerListener

        public ScheduledTimerListener​(Runnable timerTask,
                                      long delay,
                                      long period,
                                      boolean fixedRate)
        Create a new ScheduledTimerListener.
        参数:
        timerTask - the Runnable to schedule as TimerListener
        delay - the delay before starting the task for the first time (ms)
        period - the period between repeated task executions (ms)
        fixedRate - whether to schedule as fixed-rate execution
    • 方法详细资料

      • setDelay

        public void setDelay​(long delay)
        Set the delay before starting the task for the first time, in milliseconds. Default is 0, immediately starting the task after successful scheduling.

        If the "firstTime" property is specified, this property will be ignored. Specify one or the other, not both.

      • getDelay

        public long getDelay()
        Return the delay before starting the job for the first time.
      • setPeriod

        public void setPeriod​(long period)
        Set the period between repeated task executions, in milliseconds.

        Default is -1, leading to one-time execution. In case of zero or a positive value, the task will be executed repeatedly, with the given interval in-between executions.

        Note that the semantics of the period value vary between fixed-rate and fixed-delay execution.

        Note: A period of 0 (for example as fixed delay) is supported, because the CommonJ specification defines this as a legal value. Hence a value of 0 will result in immediate re-execution after a job has finished (not in one-time execution like with java.util.Timer).

        另请参阅:
        setFixedRate(boolean), isOneTimeTask(), TimerManager.schedule(commonj.timers.TimerListener, long, long)
      • getPeriod

        public long getPeriod()
        Return the period between repeated task executions.
      • isOneTimeTask

        public boolean isOneTimeTask()
        Is this task only ever going to execute once?
        返回:
        true if this task is only ever going to execute once
        另请参阅:
        getPeriod()
      • isFixedRate

        public boolean isFixedRate()
        Return whether to schedule as fixed-rate execution.