Interface TaskScheduler

    • Method Detail

      • schedule

        default ScheduledFuture<?> schedule​(Runnable task,
                                            Instant 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.

        Parameters:
        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)
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
        Since:
        5.0
        See Also:
        schedule(Runnable, Date)
      • 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.

        Parameters:
        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)
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        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

        default ScheduledFuture<?> scheduleAtFixedRate​(Runnable task,
                                                       Instant startTime,
                                                       Duration 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.

        Parameters:
        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
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
        Since:
        5.0
        See Also:
        scheduleAtFixedRate(Runnable, Date, long)
      • 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.

        Parameters:
        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)
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        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.

        Parameters:
        task - the Runnable to execute whenever the trigger fires
        period - the interval between successive executions of the task (in milliseconds)
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        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

        default ScheduledFuture<?> scheduleWithFixedDelay​(Runnable task,
                                                          Instant startTime,
                                                          Duration 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.

        Parameters:
        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
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
        Since:
        5.0
        See Also:
        scheduleWithFixedDelay(Runnable, Date, long)
      • 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.

        Parameters:
        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)
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        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

        default ScheduledFuture<?> scheduleWithFixedDelay​(Runnable task,
                                                          Duration 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.

        Parameters:
        task - the Runnable to execute whenever the trigger fires
        delay - the delay between the completion of one execution and the start of the next
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)
        Since:
        5.0
        See Also:
        scheduleWithFixedDelay(Runnable, long)
      • 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.

        Parameters:
        task - the Runnable to execute whenever the trigger fires
        delay - the delay between the completion of one execution and the start of the next (in milliseconds)
        Returns:
        a ScheduledFuture representing pending completion of the task
        Throws:
        TaskRejectedException - if the given task was not accepted for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress)