ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ScheduledThreadPoolExecutor.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ScheduledThreadPoolExecutor.java (file contents):
Revision 1.74 by jsr166, Tue Nov 12 23:06:34 2013 UTC vs.
Revision 1.75 by jsr166, Sun Feb 16 14:03:53 2014 UTC

# Line 13 | Line 13 | import java.util.*;
13  
14   /**
15   * A {@link ThreadPoolExecutor} that can additionally schedule
16 < * commands to run after a given delay, or to execute
17 < * periodically. This class is preferable to {@link java.util.Timer}
18 < * when multiple worker threads are needed, or when the additional
19 < * flexibility or capabilities of {@link ThreadPoolExecutor} (which
20 < * this class extends) are required.
16 > * commands to run after a given delay, or to execute periodically.
17 > * This class is preferable to {@link java.util.Timer} when multiple
18 > * worker threads are needed, or when the additional flexibility or
19 > * capabilities of {@link ThreadPoolExecutor} (which this class
20 > * extends) are required.
21   *
22   * <p>Delayed tasks execute no sooner than they are enabled, but
23   * without any real-time guarantees about when, after they are
# Line 26 | Line 26 | import java.util.*;
26   * submission.
27   *
28   * <p>When a submitted task is cancelled before it is run, execution
29 < * is suppressed. By default, such a cancelled task is not
30 < * automatically removed from the work queue until its delay
31 < * elapses. While this enables further inspection and monitoring, it
32 < * may also cause unbounded retention of cancelled tasks. To avoid
33 < * this, set {@link #setRemoveOnCancelPolicy} to {@code true}, which
34 < * causes tasks to be immediately removed from the work queue at
35 < * time of cancellation.
36 < *
37 < * <p>Successive executions of a task scheduled via
38 < * {@code scheduleAtFixedRate} or
39 < * {@code scheduleWithFixedDelay} do not overlap. While different
29 > * is suppressed.  By default, such a cancelled task is not
30 > * automatically removed from the work queue until its delay elapses.
31 > * While this enables further inspection and monitoring, it may also
32 > * cause unbounded retention of cancelled tasks.  To avoid this, use
33 > * {@link #setRemoveOnCancelPolicy} to cause tasks to be immediately
34 > * removed from the work queue at time of cancellation.
35 > *
36 > * <p>Successive executions of a periodic task scheduled via
37 > * {@link #scheduleAtFixedRate} or
38 > * {@link #scheduleWithFixedDelay} do not overlap. While different
39   * executions may be performed by different threads, the effects of
40   * prior executions <a
41   * href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
# Line 131 | Line 130 | public class ScheduledThreadPoolExecutor
130      private volatile boolean executeExistingDelayedTasksAfterShutdown = true;
131  
132      /**
133 <     * True if ScheduledFutureTask.cancel should remove from queue
133 >     * True if ScheduledFutureTask.cancel should remove from queue.
134       */
135      private volatile boolean removeOnCancel = false;
136  
# Line 158 | Line 157 | public class ScheduledThreadPoolExecutor
157          private long time;
158  
159          /**
160 <         * Period in nanoseconds for repeating tasks.  A positive
161 <         * value indicates fixed-rate execution.  A negative value
162 <         * indicates fixed-delay execution.  A value of 0 indicates a
163 <         * non-repeating task.
160 >         * Period in nanoseconds for repeating tasks.
161 >         * A positive value indicates fixed-rate execution.
162 >         * A negative value indicates fixed-delay execution.
163 >         * A value of 0 indicates a non-repeating (one-shot) task.
164           */
165          private final long period;
166  
# Line 176 | Line 175 | public class ScheduledThreadPoolExecutor
175          /**
176           * Creates a one-shot action with given nanoTime-based trigger time.
177           */
178 <        ScheduledFutureTask(Runnable r, V result, long ns) {
178 >        ScheduledFutureTask(Runnable r, V result, long triggerTime) {
179              super(r, result);
180 <            this.time = ns;
180 >            this.time = triggerTime;
181              this.period = 0;
182              this.sequenceNumber = sequencer.getAndIncrement();
183          }
184  
185          /**
186 <         * Creates a periodic action with given nano time and period.
186 >         * Creates a periodic action with given nanoTime-based initial
187 >         * trigger time and period.
188           */
189 <        ScheduledFutureTask(Runnable r, V result, long ns, long period) {
189 >        ScheduledFutureTask(Runnable r, V result, long triggerTime,
190 >                            long period) {
191              super(r, result);
192 <            this.time = ns;
192 >            this.time = triggerTime;
193              this.period = period;
194              this.sequenceNumber = sequencer.getAndIncrement();
195          }
# Line 196 | Line 197 | public class ScheduledThreadPoolExecutor
197          /**
198           * Creates a one-shot action with given nanoTime-based trigger time.
199           */
200 <        ScheduledFutureTask(Callable<V> callable, long ns) {
200 >        ScheduledFutureTask(Callable<V> callable, long triggerTime) {
201              super(callable);
202 <            this.time = ns;
202 >            this.time = triggerTime;
203              this.period = 0;
204              this.sequenceNumber = sequencer.getAndIncrement();
205          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines