接口 TaskScheduler

    • 方法详细资料

      • schedule

        ScheduledFuture<?> schedule​(Runnable task,
                                    Date startTime)
        Schedule the given Runnable, invoking it at the specified execution time.

        Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

        参数:
        task - the Runnable to execute whenever the trigger fires
        startTime - the desired execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)
        返回:
        a ScheduledFuture representing pending completion of the task
        抛出:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
      • scheduleAtFixedRate

        ScheduledFuture<?> scheduleAtFixedRate​(Runnable task,
                                               Date startTime,
                                               long period)
        Schedule the given Runnable, invoking it at the specified execution time and subsequently with the given period.

        Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

        参数:
        task - the Runnable to execute whenever the trigger fires
        startTime - the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)
        period - the interval between successive executions of the task (in milliseconds)
        返回:
        a ScheduledFuture representing pending completion of the task
        抛出:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
      • scheduleAtFixedRate

        ScheduledFuture<?> scheduleAtFixedRate​(Runnable task,
                                               long period)
        Schedule the given Runnable, starting as soon as possible and invoking it with the given period.

        Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

        参数:
        task - the Runnable to execute whenever the trigger fires
        period - the interval between successive executions of the task (in milliseconds)
        返回:
        a ScheduledFuture representing pending completion of the task
        抛出:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
      • scheduleWithFixedDelay

        ScheduledFuture<?> scheduleWithFixedDelay​(Runnable task,
                                                  Date startTime,
                                                  long delay)
        Schedule the given Runnable, invoking it at the specified execution time and subsequently with the given delay between the completion of one execution and the start of the next.

        Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

        参数:
        task - the Runnable to execute whenever the trigger fires
        startTime - the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)
        delay - the delay between the completion of one execution and the start of the next (in milliseconds)
        返回:
        a ScheduledFuture representing pending completion of the task
        抛出:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
      • scheduleWithFixedDelay

        ScheduledFuture<?> scheduleWithFixedDelay​(Runnable task,
                                                  long delay)
        Schedule the given Runnable, starting as soon as possible and invoking it with the given delay between the completion of one execution and the start of the next.

        Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

        参数:
        task - the Runnable to execute whenever the trigger fires
        delay - the interval between successive executions of the task (in milliseconds)
        返回:
        a ScheduledFuture representing pending completion of the task
        抛出:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)