Interface ListeningScheduledExecutorService

    • Method Detail

      • scheduleAtFixedRate

        ListenableScheduledFuture<?> scheduleAtFixedRate​(Runnable command,
                                                         long initialDelay,
                                                         long period,
                                                         TimeUnit unit)
        Description copied from interface: java.util.concurrent.ScheduledExecutorService
        Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence after initialDelay, then initialDelay + period, then initialDelay + 2 * period, and so on.

        The sequence of task executions continues indefinitely until one of the following exceptional completions occur:

        • The task is explicitly cancelled via the returned future.
        • The executor terminates, also resulting in task cancellation.
        • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
        Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.

        If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

        Specified by:
        scheduleAtFixedRate in interface ScheduledExecutorService
        Parameters:
        command - the task to execute
        initialDelay - the time to delay first execution
        period - the period between successive executions
        unit - the time unit of the initialDelay and period parameters
        Returns:
        a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
        Since:
        15.0 (previously returned ScheduledFuture)
      • scheduleWithFixedDelay

        ListenableScheduledFuture<?> scheduleWithFixedDelay​(Runnable command,
                                                            long initialDelay,
                                                            long delay,
                                                            TimeUnit unit)
        Description copied from interface: java.util.concurrent.ScheduledExecutorService
        Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.

        The sequence of task executions continues indefinitely until one of the following exceptional completions occur:

        • The task is explicitly cancelled via the returned future.
        • The executor terminates, also resulting in task cancellation.
        • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
        Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.
        Specified by:
        scheduleWithFixedDelay in interface ScheduledExecutorService
        Parameters:
        command - the task to execute
        initialDelay - the time to delay first execution
        delay - the delay between the termination of one execution and the commencement of the next
        unit - the time unit of the initialDelay and delay parameters
        Returns:
        a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
        Since:
        15.0 (previously returned ScheduledFuture)