fixed some formatting typos
[vimdoclet.git] / sample / java.util.concurrent.ScheduledThreadPoolExecutor.txt
blobd52ba2fa2c8f4da2770dbabb678750a7d80be25c
1 *java.util.concurrent.ScheduledThreadPoolExecutor* *ScheduledThreadPoolExecutor* 
3 public class ScheduledThreadPoolExecutor
4   extends    |java.util.concurrent.ThreadPoolExecutor|
5   implements |java.util.concurrent.ScheduledExecutorService|
7 |java.util.concurrent.ScheduledThreadPoolExecutor_Description|
8 |java.util.concurrent.ScheduledThreadPoolExecutor_Fields|
9 |java.util.concurrent.ScheduledThreadPoolExecutor_Constructors|
10 |java.util.concurrent.ScheduledThreadPoolExecutor_Methods|
12 ================================================================================
14 *java.util.concurrent.ScheduledThreadPoolExecutor_Constructors*
15 |java.util.concurrent.ScheduledThreadPoolExecutor(int)|Creates a new ScheduledT
16 |java.util.concurrent.ScheduledThreadPoolExecutor(int,RejectedExecutionHandler)|
17 |java.util.concurrent.ScheduledThreadPoolExecutor(int,ThreadFactory)|Creates a 
18 |java.util.concurrent.ScheduledThreadPoolExecutor(int,ThreadFactory,RejectedExecutionHandler)|
20 *java.util.concurrent.ScheduledThreadPoolExecutor_Methods*
21 |java.util.concurrent.ScheduledThreadPoolExecutor.decorateTask(Callable<V>,RunnableScheduledFuture<V>)|
22 |java.util.concurrent.ScheduledThreadPoolExecutor.decorateTask(Runnable,RunnableScheduledFuture<V>)|
23 |java.util.concurrent.ScheduledThreadPoolExecutor.execute(Runnable)|Executes co
24 |java.util.concurrent.ScheduledThreadPoolExecutor.getContinueExistingPeriodicTasksAfterShutdownPolicy()|
25 |java.util.concurrent.ScheduledThreadPoolExecutor.getExecuteExistingDelayedTasksAfterShutdownPolicy()|
26 |java.util.concurrent.ScheduledThreadPoolExecutor.getQueue()|Returns the task q
27 |java.util.concurrent.ScheduledThreadPoolExecutor.remove(Runnable)|
28 |java.util.concurrent.ScheduledThreadPoolExecutor.schedule(Callable<V>,long,TimeUnit)|
29 |java.util.concurrent.ScheduledThreadPoolExecutor.schedule(Runnable,long,TimeUnit)|
30 |java.util.concurrent.ScheduledThreadPoolExecutor.scheduleAtFixedRate(Runnable,long,long,TimeUnit)|
31 |java.util.concurrent.ScheduledThreadPoolExecutor.scheduleWithFixedDelay(Runnable,long,long,TimeUnit)|
32 |java.util.concurrent.ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean)|
33 |java.util.concurrent.ScheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean)|
34 |java.util.concurrent.ScheduledThreadPoolExecutor.shutdown()|Initiates an order
35 |java.util.concurrent.ScheduledThreadPoolExecutor.shutdownNow()|Attempts to sto
36 |java.util.concurrent.ScheduledThreadPoolExecutor.submit(Callable<T>)|
37 |java.util.concurrent.ScheduledThreadPoolExecutor.submit(Runnable)|
38 |java.util.concurrent.ScheduledThreadPoolExecutor.submit(Runnable,T)|
40 *java.util.concurrent.ScheduledThreadPoolExecutor_Description*
42 A (|java.util.concurrent.ThreadPoolExecutor|) that can additionally schedule 
43 commands to run after a given delay, or to execute periodically. This class is 
44 preferable to (|java.util.Timer|) when multiple worker threads are needed, or 
45 when the additional flexibility or capabilities of 
46 (|java.util.concurrent.ThreadPoolExecutor|) (which this class extends) are 
47 required. 
49 Delayed tasks execute no sooner than they are enabled, but without any 
50 real-time guarantees about when, after they are enabled, they will commence. 
51 Tasks scheduled for exactly the same execution time are enabled in 
52 first-in-first-out (FIFO) order of submission. 
54 While this class inherits from (|java.util.concurrent.ThreadPoolExecutor|) , a 
55 few of the inherited tuning methods are not useful for it. In particular, 
56 because it acts as a fixed-sized pool using corePoolSize threads and an 
57 unbounded queue, adjustments to maximumPoolSize have no useful effect. 
59 Extension notes: This class overrides 
60 (|java.util.concurrent.AbstractExecutorService|) submit methods to generate 
61 internal objects to control per-task delays and scheduling. To preserve 
62 functionality, any further overrides of these methods in subclasses must invoke 
63 superclass versions, which effectively disables additional task customization. 
64 However, this class provides alternative protected extension method 
65 decorateTask (one version each for Runnable and Callable) that can be used to 
66 customize the concrete task types used to execute commands entered via execute, 
67 submit, schedule, scheduleAtFixedRate, and scheduleWithFixedDelay. By default, 
68 a ScheduledThreadPoolExecutor uses a task type extending 
69 (|java.util.concurrent.FutureTask|) . However, this may be modified or replaced 
70 using subclasses of the form: 
74 public class CustomScheduledExecutor extends ScheduledThreadPoolExecutor { 
76 static class CustomTask<V> implements RunnableScheduledFuture<V> { ... } 
78 protected <V> RunnableScheduledFuture<V> decorateTask( Runnable r, 
79 RunnableScheduledFuture<V> task) { return new CustomTask<V>(r, task); } 
81 protected <V> RunnableScheduledFuture<V> decorateTask( Callable<V> c, 
82 RunnableScheduledFuture<V> task) { return new CustomTask<V>(c, task); } // ... 
83 add constructors, etc. } 
87 *java.util.concurrent.ScheduledThreadPoolExecutor(int)*
89 public ScheduledThreadPoolExecutor(int corePoolSize)
91 Creates a new ScheduledThreadPoolExecutor with the given core pool size. 
93     corePoolSize - the number of threads to keep in the pool, even if they are idle 
95 *java.util.concurrent.ScheduledThreadPoolExecutor(int,RejectedExecutionHandler)*
97 public ScheduledThreadPoolExecutor(
98   int corePoolSize,
99   java.util.concurrent.RejectedExecutionHandler handler)
101 Creates a new ScheduledThreadPoolExecutor with the given initial parameters. 
103     corePoolSize - the number of threads to keep in the pool, even if they are idle 
104     handler - the handler to use when execution is blocked because the thread bounds and 
105        queue capacities are reached 
107 *java.util.concurrent.ScheduledThreadPoolExecutor(int,ThreadFactory)*
109 public ScheduledThreadPoolExecutor(
110   int corePoolSize,
111   java.util.concurrent.ThreadFactory threadFactory)
113 Creates a new ScheduledThreadPoolExecutor with the given initial parameters. 
115     corePoolSize - the number of threads to keep in the pool, even if they are idle 
116     threadFactory - the factory to use when the executor creates a new thread 
118 *java.util.concurrent.ScheduledThreadPoolExecutor(int,ThreadFactory,RejectedExecutionHandler)*
120 public ScheduledThreadPoolExecutor(
121   int corePoolSize,
122   java.util.concurrent.ThreadFactory threadFactory,
123   java.util.concurrent.RejectedExecutionHandler handler)
125 Creates a new ScheduledThreadPoolExecutor with the given initial parameters. 
127     corePoolSize - the number of threads to keep in the pool, even if they are idle 
128     threadFactory - the factory to use when the executor creates a new thread 
129     handler - the handler to use when execution is blocked because the thread bounds and 
130        queue capacities are reached. 
132 *java.util.concurrent.ScheduledThreadPoolExecutor.decorateTask(Callable<V>,RunnableScheduledFuture<V>)*
134 protected |java.util.concurrent.RunnableScheduledFuture|<V> decorateTask(
135   java.util.concurrent.Callable<V> callable,
136   java.util.concurrent.RunnableScheduledFuture<V> task)
138 Modifies or replaces the task used to execute a callable. This method can be 
139 used to override the concrete class used for managing internal tasks. The 
140 default implementation simply returns the given task. 
143     callable - the submitted Callable 
144     task - the task created to execute the callable 
146     Returns: a task that can execute the callable 
148 *java.util.concurrent.ScheduledThreadPoolExecutor.decorateTask(Runnable,RunnableScheduledFuture<V>)*
150 protected |java.util.concurrent.RunnableScheduledFuture|<V> decorateTask(
151   java.lang.Runnable runnable,
152   java.util.concurrent.RunnableScheduledFuture<V> task)
154 Modifies or replaces the task used to execute a runnable. This method can be 
155 used to override the concrete class used for managing internal tasks. The 
156 default implementation simply returns the given task. 
159     runnable - the submitted Runnable 
160     task - the task created to execute the runnable 
162     Returns: a task that can execute the runnable 
164 *java.util.concurrent.ScheduledThreadPoolExecutor.execute(Runnable)*
166 public void execute(java.lang.Runnable command)
168 Executes command with zero required delay. This has effect equivalent to 
169 schedule(command, 0, anyUnit). Note that inspections of the queue and of the 
170 list returned by shutdownNow will access the zero-delayed 
171 (|java.util.concurrent.ScheduledFuture|) , not the command itself. 
174     command - the task to execute 
176 *java.util.concurrent.ScheduledThreadPoolExecutor.getContinueExistingPeriodicTasksAfterShutdownPolicy()*
178 public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy()
180 Gets the policy on whether to continue executing existing periodic tasks even 
181 when this executor has been shutdown. In this case, these tasks will only 
182 terminate upon shutdownNow or after setting the policy to false when already 
183 shutdown. This value is by default false. 
187     Returns: true if will continue after shutdown 
189 *java.util.concurrent.ScheduledThreadPoolExecutor.getExecuteExistingDelayedTasksAfterShutdownPolicy()*
191 public boolean getExecuteExistingDelayedTasksAfterShutdownPolicy()
193 Gets the policy on whether to execute existing delayed tasks even when this 
194 executor has been shutdown. In this case, these tasks will only terminate upon 
195 shutdownNow, or after setting the policy to false when already shutdown. This 
196 value is by default true. 
200     Returns: true if will execute after shutdown 
202 *java.util.concurrent.ScheduledThreadPoolExecutor.getQueue()*
204 public |java.util.concurrent.BlockingQueue|<Runnable> getQueue()
206 Returns the task queue used by this executor. Each element of this queue is a 
207 (|java.util.concurrent.ScheduledFuture|) , including those tasks submitted 
208 using execute which are for scheduling purposes used as the basis of a 
209 zero-delay ScheduledFuture. Iteration over this queue is not guaranteed to 
210 traverse tasks in the order in which they will execute. 
214     Returns: the task queue 
216 *java.util.concurrent.ScheduledThreadPoolExecutor.remove(Runnable)*
218 public boolean remove(java.lang.Runnable task)
224 *java.util.concurrent.ScheduledThreadPoolExecutor.schedule(Callable<V>,long,TimeUnit)*
226 public |java.util.concurrent.ScheduledFuture|<V> schedule(
227   java.util.concurrent.Callable<V> callable,
228   long delay,
229   java.util.concurrent.TimeUnit unit)
235 *java.util.concurrent.ScheduledThreadPoolExecutor.schedule(Runnable,long,TimeUnit)*
237 public |java.util.concurrent.ScheduledFuture|<?> schedule(
238   java.lang.Runnable command,
239   long delay,
240   java.util.concurrent.TimeUnit unit)
246 *java.util.concurrent.ScheduledThreadPoolExecutor.scheduleAtFixedRate(Runnable,long,long,TimeUnit)*
248 public |java.util.concurrent.ScheduledFuture|<?> scheduleAtFixedRate(
249   java.lang.Runnable command,
250   long initialDelay,
251   long period,
252   java.util.concurrent.TimeUnit unit)
258 *java.util.concurrent.ScheduledThreadPoolExecutor.scheduleWithFixedDelay(Runnable,long,long,TimeUnit)*
260 public |java.util.concurrent.ScheduledFuture|<?> scheduleWithFixedDelay(
261   java.lang.Runnable command,
262   long initialDelay,
263   long delay,
264   java.util.concurrent.TimeUnit unit)
270 *java.util.concurrent.ScheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean)*
272 public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean value)
274 Sets the policy on whether to continue executing existing periodic tasks even 
275 when this executor has been shutdown. In this case, these tasks will only 
276 terminate upon shutdownNow, or after setting the policy to false when already 
277 shutdown. This value is by default false. 
280     value - if true, continue after shutdown, else don't. 
282 *java.util.concurrent.ScheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean)*
284 public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean value)
286 Sets the policy on whether to execute existing delayed tasks even when this 
287 executor has been shutdown. In this case, these tasks will only terminate upon 
288 shutdownNow, or after setting the policy to false when already shutdown. This 
289 value is by default true. 
292     value - if true, execute after shutdown, else don't. 
294 *java.util.concurrent.ScheduledThreadPoolExecutor.shutdown()*
296 public void shutdown()
298 Initiates an orderly shutdown in which previously submitted tasks are executed, 
299 but no new tasks will be accepted. If the 
300 ExecuteExistingDelayedTasksAfterShutdownPolicy has been set false, existing 
301 delayed tasks whose delays have not yet elapsed are cancelled. And unless the 
302 ContinueExistingPeriodicTasksAfterShutdownPolicy has been set true, future 
303 executions of existing periodic tasks will be cancelled. 
307 *java.util.concurrent.ScheduledThreadPoolExecutor.shutdownNow()*
309 public |java.util.List|<Runnable> shutdownNow()
311 Attempts to stop all actively executing tasks, halts the processing of waiting 
312 tasks, and returns a list of the tasks that were awaiting execution. 
314 There are no guarantees beyond best-effort attempts to stop processing actively 
315 executing tasks. This implementation cancels tasks via (|java.lang.Thread|) , 
316 so any task that fails to respond to interrupts may never terminate. 
320     Returns: list of tasks that never commenced execution. Each element of this list is a 
321              {@link ScheduledFuture}, including those tasks submitted using 
322              execute, which are for scheduling purposes used as the basis of a 
323              zero-delay ScheduledFuture. 
325 *java.util.concurrent.ScheduledThreadPoolExecutor.submit(Callable<T>)*
327 public |java.util.concurrent.Future|<T> submit(java.util.concurrent.Callable<T> task)
333 *java.util.concurrent.ScheduledThreadPoolExecutor.submit(Runnable)*
335 public |java.util.concurrent.Future|<?> submit(java.lang.Runnable task)
341 *java.util.concurrent.ScheduledThreadPoolExecutor.submit(Runnable,T)*
343 public |java.util.concurrent.Future|<T> submit(
344   java.lang.Runnable task,
345   T result)