1 *java.util.concurrent.CompletionService* *CompletionService* A service that deco
3 public interface interface CompletionService
6 |java.util.concurrent.CompletionService_Description|
7 |java.util.concurrent.CompletionService_Fields|
8 |java.util.concurrent.CompletionService_Constructors|
9 |java.util.concurrent.CompletionService_Methods|
11 ================================================================================
13 *java.util.concurrent.CompletionService_Methods*
14 |java.util.concurrent.CompletionService.poll()|Retrieves and removes the Future
15 |java.util.concurrent.CompletionService.poll(long,TimeUnit)|Retrieves and remov
16 |java.util.concurrent.CompletionService.submit(Callable)|Submits a value-return
17 |java.util.concurrent.CompletionService.submit(Runnable,V)|Submits a Runnable t
18 |java.util.concurrent.CompletionService.take()|Retrieves and removes the Future
20 *java.util.concurrent.CompletionService_Description*
22 A service that decouples the production of new asynchronous tasks from the
23 consumption of the results of completed tasks. Producers submit tasks for
24 execution. Consumers take completed tasks and process their results in the
25 order they complete. A CompletionService can for example be used to manage
26 asynchronous IO, in which tasks that perform reads are submitted in one part of
27 a program or system, and then acted upon in a different part of the program
28 when the reads complete, possibly in a different order than they were
33 Typically, a CompletionService relies on a separate
34 (|java.util.concurrent.Executor|) to actually execute the tasks, in which case
35 the CompletionService only manages an internal completion queue. The
36 (|java.util.concurrent.ExecutorCompletionService|) class provides an
37 implementation of this approach.
40 *java.util.concurrent.CompletionService.poll()*
42 public |java.util.concurrent.Future| poll()
44 Retrieves and removes the Future representing the next completed task or null
48 Returns: the Future representing the next completed task, or null if none are present.
49 *java.util.concurrent.CompletionService.poll(long,TimeUnit)*
51 public |java.util.concurrent.Future| poll(
53 java.util.concurrent.TimeUnit unit)
54 throws |java.lang.InterruptedException|
56 Retrieves and removes the Future representing the next completed task, waiting
57 if necessary up to the specified wait time if none are yet present.
59 timeout - how long to wait before giving up, in units of unit
60 unit - a TimeUnit determining how to interpret the timeout parameter
62 Returns: the Future representing the next completed task or null if the specified
63 waiting time elapses before one is present.
64 *java.util.concurrent.CompletionService.submit(Callable)*
66 public |java.util.concurrent.Future| submit(java.util.concurrent.Callable task)
68 Submits a value-returning task for execution and returns a Future representing
69 the pending results of the task. Upon completion, this task may be taken or
72 task - the task to submit
74 Returns: a Future representing pending completion of the task
75 *java.util.concurrent.CompletionService.submit(Runnable,V)*
77 public |java.util.concurrent.Future| submit(
78 java.lang.Runnable task,
79 java.lang.Object result)
81 Submits a Runnable task for execution and returns a Future representing that
82 task.Upon completion, this task may be taken or polled.
84 task - the task to submit
85 result - the result to return upon successful completion
87 Returns: a Future representing pending completion of the task, and whose get() method
88 will return the given result value upon completion
89 *java.util.concurrent.CompletionService.take()*
91 public |java.util.concurrent.Future| take()
92 throws |java.lang.InterruptedException|
94 Retrieves and removes the Future representing the next completed task, waiting
95 if none are yet present.
98 Returns: the Future representing the next completed task