jdk/src/java.base/share/classes/java/util/concurrent/ScheduledExecutorService.java
author dl
Wed, 21 Dec 2016 14:26:52 -0800
changeset 42927 1d31e540bfcb
parent 42322 c3474fef4fe4
child 45936 d564ef4bed8f
permissions -rw-r--r--
8170484: Miscellaneous changes imported from jsr166 CVS 2016-12 Reviewed-by: martin, smarks, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * This file is available under and governed by the GNU General Public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * License version 2 only, as published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * However, the following notice accompanied the original version of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Written by Doug Lea with assistance from members of JCP JSR-166
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Expert Group and released to the public domain, as explained at
9242
ef138d47df58 7034657: Update Creative Commons license URL in legal notices
dl
parents: 7518
diff changeset
    33
 * http://creativecommons.org/publicdomain/zero/1.0/
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
package java.util.concurrent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * An {@link ExecutorService} that can schedule commands to run after a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * delay, or to execute periodically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    42
 * <p>The {@code schedule} methods create tasks with various delays
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * and return a task object that can be used to cancel or check
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    44
 * execution. The {@code scheduleAtFixedRate} and
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    45
 * {@code scheduleWithFixedDelay} methods create and execute tasks
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * that run periodically until cancelled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    48
 * <p>Commands submitted using the {@link Executor#execute(Runnable)}
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    49
 * and {@link ExecutorService} {@code submit} methods are scheduled
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    50
 * with a requested delay of zero. Zero and negative delays (but not
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    51
 * periods) are also allowed in {@code schedule} methods, and are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * treated as requests for immediate execution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    54
 * <p>All {@code schedule} methods accept <em>relative</em> delays and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * periods as arguments, not absolute times or dates. It is a simple
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * matter to transform an absolute time represented as a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * java.util.Date} to the required form. For example, to schedule at
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    58
 * a certain future {@code date}, you can use: {@code schedule(task,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * date.getTime() - System.currentTimeMillis(),
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    60
 * TimeUnit.MILLISECONDS)}. Beware however that expiration of a
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    61
 * relative delay need not coincide with the current {@code Date} at
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * which the task is enabled due to network time synchronization
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * protocols, clock drift, or other factors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
    65
 * <p>The {@link Executors} class provides convenient factory methods for
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * the ScheduledExecutorService implementations provided in this package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <h3>Usage Example</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * Here is a class with a method that sets up a ScheduledExecutorService
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * to beep every ten seconds for an hour:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    73
 * <pre> {@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * import static java.util.concurrent.TimeUnit.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * class BeeperControl {
7518
0282db800fe1 7003745: Code style cleanups (sync from Dougs CVS)
dl
parents: 5506
diff changeset
    76
 *   private final ScheduledExecutorService scheduler =
0282db800fe1 7003745: Code style cleanups (sync from Dougs CVS)
dl
parents: 5506
diff changeset
    77
 *     Executors.newScheduledThreadPool(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
7518
0282db800fe1 7003745: Code style cleanups (sync from Dougs CVS)
dl
parents: 5506
diff changeset
    79
 *   public void beepForAnHour() {
42322
c3474fef4fe4 8166646: Miscellaneous changes imported from jsr166 CVS 2016-10
dl
parents: 32991
diff changeset
    80
 *     Runnable beeper = () -> System.out.println("beep");
c3474fef4fe4 8166646: Miscellaneous changes imported from jsr166 CVS 2016-10
dl
parents: 32991
diff changeset
    81
 *     ScheduledFuture<?> beeperHandle =
7518
0282db800fe1 7003745: Code style cleanups (sync from Dougs CVS)
dl
parents: 5506
diff changeset
    82
 *       scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
42322
c3474fef4fe4 8166646: Miscellaneous changes imported from jsr166 CVS 2016-10
dl
parents: 32991
diff changeset
    83
 *     Runnable canceller = () -> beeperHandle.cancel(true);
c3474fef4fe4 8166646: Miscellaneous changes imported from jsr166 CVS 2016-10
dl
parents: 32991
diff changeset
    84
 *     scheduler.schedule(canceller, 1, HOURS);
7518
0282db800fe1 7003745: Code style cleanups (sync from Dougs CVS)
dl
parents: 5506
diff changeset
    85
 *   }
0282db800fe1 7003745: Code style cleanups (sync from Dougs CVS)
dl
parents: 5506
diff changeset
    86
 * }}</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * @author Doug Lea
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
public interface ScheduledExecutorService extends ExecutorService {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Creates and executes a one-shot action that becomes enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * after the given delay.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param command the task to execute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param delay the time from now to delay execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param unit the time unit of the delay parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @return a ScheduledFuture representing pending completion of
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
   101
     *         the task and whose {@code get()} method will return
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
   102
     *         {@code null} upon completion
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @throws RejectedExecutionException if the task cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *         scheduled for execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @throws NullPointerException if command is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public ScheduledFuture<?> schedule(Runnable command,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                       long delay, TimeUnit unit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Creates and executes a ScheduledFuture that becomes enabled after the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * given delay.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @param callable the function to execute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @param delay the time from now to delay execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @param unit the time unit of the delay parameter
19048
7d0a94c79779 8021417: Fix doclint issues in java.util.concurrent
chegar
parents: 18790
diff changeset
   117
     * @param <V> the type of the callable's result
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @return a ScheduledFuture that can be used to extract result or cancel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @throws RejectedExecutionException if the task cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *         scheduled for execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @throws NullPointerException if callable is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public <V> ScheduledFuture<V> schedule(Callable<V> callable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                                           long delay, TimeUnit unit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Creates and executes a periodic action that becomes enabled first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * after the given initial delay, and subsequently with the given
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   129
     * period; that is, executions will commence after
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   130
     * {@code initialDelay}, then {@code initialDelay + period}, then
18790
d25399d849bc 8019370: Sync j.u.c Fork/Join from 166 to tl
psandoz
parents: 14325
diff changeset
   131
     * {@code initialDelay + 2 * period}, and so on.
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   132
     *
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   133
     * <p>The sequence of task executions continues indefinitely until
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   134
     * one of the following exceptional completions occur:
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   135
     * <ul>
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   136
     * <li>The task is {@linkplain Future#cancel explicitly cancelled}
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   137
     * via the returned future.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   138
     * <li>The executor terminates, also resulting in task cancellation.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   139
     * <li>An execution of the task throws an exception.  In this case
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   140
     * calling {@link Future#get() get} on the returned future will
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   141
     * throw {@link ExecutionException}.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   142
     * </ul>
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   143
     * Subsequent executions are suppressed.  Subsequent calls to
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   144
     * {@link Future#isDone isDone()} on the returned future will
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   145
     * return {@code true}.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   146
     *
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   147
     * <p>If any execution of this task takes longer than its period, then
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   148
     * subsequent executions may start late, but will not concurrently
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   149
     * execute.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param command the task to execute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @param initialDelay the time to delay first execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param period the period between successive executions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param unit the time unit of the initialDelay and period parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @return a ScheduledFuture representing pending completion of
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   156
     *         the series of repeated tasks.  The future's {@link
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   157
     *         Future#get() get()} method will never return normally,
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   158
     *         and will throw an exception upon task cancellation or
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   159
     *         abnormal termination of a task execution.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @throws RejectedExecutionException if the task cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *         scheduled for execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @throws NullPointerException if command is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @throws IllegalArgumentException if period less than or equal to zero
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                                  long initialDelay,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                                  long period,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                                  TimeUnit unit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Creates and executes a periodic action that becomes enabled first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * after the given initial delay, and subsequently with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * given delay between the termination of one execution and the
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   174
     * commencement of the next.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   175
     *
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   176
     * <p>The sequence of task executions continues indefinitely until
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   177
     * one of the following exceptional completions occur:
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   178
     * <ul>
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   179
     * <li>The task is {@linkplain Future#cancel explicitly cancelled}
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   180
     * via the returned future.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   181
     * <li>The executor terminates, also resulting in task cancellation.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   182
     * <li>An execution of the task throws an exception.  In this case
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   183
     * calling {@link Future#get() get} on the returned future will
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   184
     * throw {@link ExecutionException}.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   185
     * </ul>
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   186
     * Subsequent executions are suppressed.  Subsequent calls to
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   187
     * {@link Future#isDone isDone()} on the returned future will
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   188
     * return {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param command the task to execute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @param initialDelay the time to delay first execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @param delay the delay between the termination of one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * execution and the commencement of the next
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @param unit the time unit of the initialDelay and delay parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @return a ScheduledFuture representing pending completion of
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   196
     *         the series of repeated tasks.  The future's {@link
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   197
     *         Future#get() get()} method will never return normally,
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   198
     *         and will throw an exception upon task cancellation or
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   199
     *         abnormal termination of a task execution.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @throws RejectedExecutionException if the task cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *         scheduled for execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @throws NullPointerException if command is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @throws IllegalArgumentException if delay less than or equal to zero
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                                     long initialDelay,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                                                     long delay,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                                     TimeUnit unit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
}