102 |
|
private final long period; |
103 |
|
|
104 |
|
/** |
105 |
< |
* Creates a one-shot action with given nanoTime-based trigger time |
105 |
> |
* Creates a one-shot action with given nanoTime-based trigger time. |
106 |
|
*/ |
107 |
|
ScheduledFutureTask(Runnable r, V result, long ns) { |
108 |
|
super(r, result); |
112 |
|
} |
113 |
|
|
114 |
|
/** |
115 |
< |
* Creates a periodic action with given nano time and period |
115 |
> |
* Creates a periodic action with given nano time and period. |
116 |
|
*/ |
117 |
< |
ScheduledFutureTask(Runnable r, V result, long ns, long period) { |
117 |
> |
ScheduledFutureTask(Runnable r, V result, long ns, long period) { |
118 |
|
super(r, result); |
119 |
|
this.time = ns; |
120 |
|
this.period = period; |
122 |
|
} |
123 |
|
|
124 |
|
/** |
125 |
< |
* Creates a one-shot action with given nanoTime-based trigger |
125 |
> |
* Creates a one-shot action with given nanoTime-based trigger. |
126 |
|
*/ |
127 |
|
ScheduledFutureTask(Callable<V> callable, long ns) { |
128 |
|
super(callable); |
153 |
|
|
154 |
|
/** |
155 |
|
* Returns true if this is a periodic (not a one-shot) action. |
156 |
+ |
* |
157 |
|
* @return true if periodic |
158 |
|
*/ |
159 |
|
public boolean isPeriodic() { |
161 |
|
} |
162 |
|
|
163 |
|
/** |
164 |
< |
* Run a periodic task |
164 |
> |
* Runs a periodic task. |
165 |
|
*/ |
166 |
|
private void runPeriodic() { |
167 |
|
boolean ok = ScheduledFutureTask.super.runAndReset(); |
242 |
|
} |
243 |
|
|
244 |
|
/** |
245 |
< |
* Modify or replace the task used to execute a runnable. |
245 |
> |
* Modifies or replaces the task used to execute a runnable. |
246 |
|
* This method can be used to override the concrete |
247 |
|
* class used for managing internal tasks. |
248 |
< |
* The default implementation simply returns the given |
248 |
< |
* task. |
248 |
> |
* The default implementation simply returns the given task. |
249 |
|
* |
250 |
|
* @param runnable the submitted Runnable |
251 |
|
* @param task the task created to execute the runnable |
258 |
|
} |
259 |
|
|
260 |
|
/** |
261 |
< |
* Modify or replace the task used to execute a callable. |
261 |
> |
* Modifies or replaces the task used to execute a callable. |
262 |
|
* This method can be used to override the concrete |
263 |
|
* class used for managing internal tasks. |
264 |
< |
* The default implementation simply returns the given |
265 |
< |
* task. |
264 |
> |
* The default implementation simply returns the given task. |
265 |
|
* |
266 |
|
* @param callable the submitted Callable |
267 |
|
* @param task the task created to execute the callable |
278 |
|
* pool size. |
279 |
|
* |
280 |
|
* @param corePoolSize the number of threads to keep in the pool, |
281 |
< |
* even if they are idle. |
281 |
> |
* even if they are idle |
282 |
|
* @throws IllegalArgumentException if <tt>corePoolSize <= 0</tt> |
283 |
|
*/ |
284 |
|
public ScheduledThreadPoolExecutor(int corePoolSize) { |
291 |
|
* initial parameters. |
292 |
|
* |
293 |
|
* @param corePoolSize the number of threads to keep in the pool, |
294 |
< |
* even if they are idle. |
294 |
> |
* even if they are idle |
295 |
|
* @param threadFactory the factory to use when the executor |
296 |
< |
* creates a new thread. |
296 |
> |
* creates a new thread |
297 |
|
* @throws IllegalArgumentException if <tt>corePoolSize <= 0</tt> |
298 |
|
* @throws NullPointerException if threadFactory is null |
299 |
|
*/ |
308 |
|
* initial parameters. |
309 |
|
* |
310 |
|
* @param corePoolSize the number of threads to keep in the pool, |
311 |
< |
* even if they are idle. |
311 |
> |
* even if they are idle |
312 |
|
* @param handler the handler to use when execution is blocked |
313 |
< |
* because the thread bounds and queue capacities are reached. |
313 |
> |
* because the thread bounds and queue capacities are reached |
314 |
|
* @throws IllegalArgumentException if <tt>corePoolSize <= 0</tt> |
315 |
|
* @throws NullPointerException if handler is null |
316 |
|
*/ |
325 |
|
* initial parameters. |
326 |
|
* |
327 |
|
* @param corePoolSize the number of threads to keep in the pool, |
328 |
< |
* even if they are idle. |
328 |
> |
* even if they are idle |
329 |
|
* @param threadFactory the factory to use when the executor |
330 |
< |
* creates a new thread. |
330 |
> |
* creates a new thread |
331 |
|
* @param handler the handler to use when execution is blocked |
332 |
|
* because the thread bounds and queue capacities are reached. |
333 |
|
* @throws IllegalArgumentException if <tt>corePoolSize <= 0</tt> |
445 |
|
* <tt>shutdownNow</tt>, or after setting the policy to |
446 |
|
* <tt>false</tt> when already shutdown. This value is by default |
447 |
|
* false. |
448 |
+ |
* |
449 |
|
* @param value if true, continue after shutdown, else don't. |
450 |
|
* @see #getContinueExistingPeriodicTasksAfterShutdownPolicy |
451 |
|
*/ |
462 |
|
* terminate upon <tt>shutdownNow</tt> or after setting the policy |
463 |
|
* to <tt>false</tt> when already shutdown. This value is by |
464 |
|
* default false. |
465 |
< |
* @return true if will continue after shutdown. |
465 |
> |
* |
466 |
> |
* @return true if will continue after shutdown |
467 |
|
* @see #setContinueExistingPeriodicTasksAfterShutdownPolicy |
468 |
|
*/ |
469 |
|
public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy() { |
477 |
|
* <tt>shutdownNow</tt>, or after setting the policy to |
478 |
|
* <tt>false</tt> when already shutdown. This value is by default |
479 |
|
* true. |
480 |
+ |
* |
481 |
|
* @param value if true, execute after shutdown, else don't. |
482 |
|
* @see #getExecuteExistingDelayedTasksAfterShutdownPolicy |
483 |
|
*/ |
494 |
|
* <tt>shutdownNow</tt>, or after setting the policy to |
495 |
|
* <tt>false</tt> when already shutdown. This value is by default |
496 |
|
* true. |
497 |
< |
* @return true if will execute after shutdown. |
497 |
> |
* |
498 |
> |
* @return true if will execute after shutdown |
499 |
|
* @see #setExecuteExistingDelayedTasksAfterShutdownPolicy |
500 |
|
*/ |
501 |
|
public boolean getExecuteExistingDelayedTasksAfterShutdownPolicy() { |
520 |
|
|
521 |
|
/** |
522 |
|
* Attempts to stop all actively executing tasks, halts the |
523 |
< |
* processing of waiting tasks, and returns a list of the tasks that were |
524 |
< |
* awaiting execution. |
523 |
> |
* processing of waiting tasks, and returns a list of the tasks |
524 |
> |
* that were awaiting execution. |
525 |
|
* |
526 |
|
* <p>There are no guarantees beyond best-effort attempts to stop |
527 |
|
* processing actively executing tasks. This implementation |
575 |
|
public boolean offer(Runnable x) { |
576 |
|
return dq.offer((RunnableScheduledFuture)x); |
577 |
|
} |
578 |
< |
public void put(Runnable x) { |
578 |
> |
public void put(Runnable x) { |
579 |
|
dq.put((RunnableScheduledFuture)x); |
580 |
|
} |
581 |
|
public boolean offer(Runnable x, long timeout, TimeUnit unit) { |
602 |
|
private Iterator<RunnableScheduledFuture> it = dq.iterator(); |
603 |
|
public boolean hasNext() { return it.hasNext(); } |
604 |
|
public Runnable next() { return it.next(); } |
605 |
< |
public void remove() { it.remove(); } |
605 |
> |
public void remove() { it.remove(); } |
606 |
|
}; |
607 |
|
} |
608 |
|
} |