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

Comparing jsr166/src/main/java/util/concurrent/ExecutorService.java (file contents):
Revision 1.17 by dl, Fri Dec 19 14:42:25 2003 UTC vs.
Revision 1.18 by dl, Fri Dec 19 20:38:31 2003 UTC

# Line 23 | Line 23 | import java.security.PrivilegedException
23   * executing, no tasks are awaiting execution, and no new tasks can be
24   * submitted.
25   *
26 < * <p> Method <tt>submit</tt> and related methods extend base method
27 < * <tt>execute</tt> by creating and returning a {@link Future} that
28 < * can be used to cancel execution and/or wait for completion.
29 < * Methods <tt>invokeAny</tt> and <tt>invokeAll</tt> perform the most
30 < * commonly useful forms of bulk execution, executing a collection of
31 < * tasks and then waiting for at least one, or all to complete. (Class
32 < * {@link ExecutorCompletionService} can be used to write customizable
26 > * <p> Method <tt>submit</tt> extends base method <tt>execute</tt> by
27 > * creating and returning a {@link Future} that can be used to cancel
28 > * execution and/or wait for completion.  Methods <tt>invokeAny</tt>
29 > * and <tt>invokeAll</tt> perform the most commonly useful forms of
30 > * bulk execution, executing a collection of tasks and then waiting
31 > * for at least one, or all to complete. (Class {@link
32 > * ExecutorCompletionService} can be used to write customizable
33   * versions of such methods.)
34   *
35   * <p>The {@link Executors} class provides factory methods for the
# Line 105 | Line 105 | public interface ExecutorService extends
105  
106  
107      /**
108     * Submits a Runnable task for execution and returns a Future
109     * representing that task.
110     *
111     * @param task the task to submit
112     * @param result the result to return upon completion
113     * If you do not need a particular result, consider using
114     * the form: <tt>Future&lt;?&gt; cancellationHandle = e.submit(task, null)</tt>.
115     * @return a Future representing pending completion of the task,
116     * and whose <tt>get()</tt> method will return the given value
117     * upon completion
118     * @throws RejectedExecutionException if task cannot be scheduled
119     * for execution
120     */
121    <T> Future<T> submit(Runnable task, T result);
122
123    /**
108       * Submits a value-returning task for execution and returns a Future
109       * representing the pending results of the task.
110       *
# Line 131 | Line 115 | public interface ExecutorService extends
115       */
116      <T> Future<T> submit(Callable<T> task);
117  
134
118      /**
119 <     * Submits a privileged action for execution under the current
120 <     * access control context and returns a Future representing the
138 <     * pending result object of that action.
139 <     *
140 <     * @param action the action to submit
141 <     * @return a Future representing pending completion of the action
142 <     * @throws RejectedExecutionException if action cannot be scheduled
143 <     * for execution
144 <     */
145 <    Future<Object> submit(PrivilegedAction action);
146 <
147 <    /**
148 <     * Submits a privileged exception action for execution under the current
149 <     * access control context and returns a Future representing the pending
150 <     * result object of that action.
151 <     *
152 <     * @param action the action to submit
153 <     * @return a Future representing pending completion of the action
154 <     * @throws RejectedExecutionException if action cannot be scheduled
155 <     * for execution
156 <     */
157 <    Future<Object> submit(PrivilegedExceptionAction action);
158 <    
159 <    /**
160 <     * Executes a Runnable task and blocks until it completes normally
161 <     * or throws an exception.
119 >     * Submits a Runnable task for execution and returns a Future
120 >     * representing that task.
121       *
122       * @param task the task to submit
123 +     * @return a Future representing pending completion of the task,
124 +     * and whose <tt>get()</tt> method will return <tt>null</tt>
125 +     * upon completion.
126       * @throws RejectedExecutionException if task cannot be scheduled
127       * for execution
166     * @throws ExecutionException if the task encountered an exception
167     * while executing
128       */
129 <    void invoke(Runnable task) throws ExecutionException, InterruptedException;
129 >    Future<?> submit(Runnable task);
130  
131      /**
132       * Executes a value-returning task and blocks until it returns a
# Line 184 | Line 144 | public interface ExecutorService extends
144      <T> T invoke(Callable<T> task) throws ExecutionException, InterruptedException;
145  
146      /**
187     * Executes the given tasks, returning when
188     * all of them complete.
189     * Note that a <em>completed</em> task could have
190     * terminated either normally or by throwing an exception.
191     * @param tasks the collection of tasks
192     * @param result value for each task to return upon completion.
193     * If you do not need a particular result, consider using <tt>null</tt>.
194     * @return A list of Futures representing the tasks, in the same
195     * sequential order as as produced by the iterator for the given task list, each of which has
196     * completed.
197     * @throws InterruptedException if interrupted while waiting, in
198     * which case unfinished tasks are cancelled.
199     * @throws NullPointerException if tasks or any of its elements are <tt>null</tt>
200     * @throws RejectedExecutionException if any task cannot be scheduled
201     * for execution
202     */
203    <T> List<Future<T>> invokeAll(Collection<Runnable> tasks, T result)
204        throws InterruptedException;
205
206    /**
207     * Executes the given tasks, returning normally
208     * when all complete or the given timeout expires, whichever
209     * happens first.
210     * Upon return, tasks that have not completed are cancelled.
211     * Note that a <em>completed</em> task could have
212     * terminated either normally or by throwing an exception.
213     * @param tasks the collection of tasks
214     * @param result value for each task to return upon completion.
215     * If you do not need a particular result, consider using <tt>null</tt>.
216     * @param timeout the maximum time to wait
217     * @return A list of Futures representing the tasks, in the same
218     * sequential order as as produced by the iterator for the given task list. If the operation did
219     * not time out, each task will have completed. If it did time
220     * out, some of these tasks will not have completed.
221     * @param unit the time unit of the timeout argument
222     * @throws InterruptedException if interrupted while waiting, in
223     * which case unfinished tasks are cancelled.
224     * @throws NullPointerException if tasks, any of its elements, or unit are <tt>null</tt>
225     * @throws RejectedExecutionException if any task cannot be scheduled
226     * for execution
227     */
228    <T> List<Future<T>> invokeAll(Collection<Runnable> tasks, T result,
229                               long timeout, TimeUnit unit)
230        throws InterruptedException;
231
232
233    /**
147       * Executes the given tasks, returning their results
148       * when all complete.
149       * Note that a <em>completed</em> task could have
# Line 270 | Line 183 | public interface ExecutorService extends
183       * for execution
184       */
185      <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks,
186 <                                long timeout, TimeUnit unit)
186 >                                  long timeout, TimeUnit unit)
187          throws InterruptedException;
188  
276
189      /**
190       * Executes the given tasks, returning the result
191       * of one that has completed successfully (i.e., without throwing
# Line 289 | Line 201 | public interface ExecutorService extends
201       * @throws RejectedExecutionException if tasks cannot be scheduled
202       * for execution
203       */
292
204      <T> T invokeAny(Collection<Callable<T>> tasks)
205          throws InterruptedException, ExecutionException;
206  
# Line 316 | Line 227 | public interface ExecutorService extends
227                      long timeout, TimeUnit unit)
228          throws InterruptedException, ExecutionException, TimeoutException;
229  
319    /**
320     * Executes the given tasks, returning the given
321     * result if one completes successfully (i.e., without
322     * throwing an exception). Upon normal or exceptional
323     * return, tasks that have not completed are cancelled.
324     * @param tasks the collection of tasks
325     * @param result the result to return upon successful completion
326     * @return the given result
327     * @throws InterruptedException if interrupted while waiting
328     * @throws NullPointerException if tasks or any of its elements
329     * are <tt>null</tt>
330     * @throws IllegalArgumentException if tasks empty
331     * @throws ExecutionException if no task successfully completes
332     * @throws RejectedExecutionException if tasks cannot be scheduled
333     * for execution
334     */
335
336    <T> T invokeAny(Collection<Runnable> tasks, T result)
337        throws InterruptedException, ExecutionException;
338
339    /**
340     * Executes the given tasks, returning the given result
341     * if one completes successfully (i.e., without throwing
342     * an exception) before the given timeout elapses.
343     * Upon normal or exceptional return, tasks that have not
344     * completed are cancelled.
345     * @param tasks the collection of tasks
346     * @param result the result to return upon successful completion
347     * @param timeout the maximum time to wait
348     * @param unit the time unit of the timeout argument
349     * @return the given result
350     * @throws InterruptedException if interrupted while waiting
351     * @throws NullPointerException if tasks, any of its elements, or
352     * unit are <tt>null</tt>
353     * @throws TimeoutException if the given timeout elapses before
354     * any task successfully completes
355     * @throws ExecutionException if no task successfully completes
356     * @throws RejectedExecutionException if tasks cannot be scheduled
357     * for execution
358     */
359    <T> T invokeAny(Collection<Runnable> tasks, T result,
360                    long timeout, TimeUnit unit)
361        throws InterruptedException, ExecutionException, TimeoutException;
362
363
230   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines