|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.4.0) E13403-05 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.model.concurrent.AsynchronousCallableCompletionService<T>
T
- the types of results that the submitted Callable
s are to have.public final class AsynchronousCallableCompletionService<T>
Wraps a CompletionService
and provides an abstraction for
submitting a set of Callable
s, along with a single callback class, CallableResultHandler
,
for processing the result/exception of every Callable
.
class MyAsyncProcessor
{
final static int NUMBER_OF_THREADS = 1000;
CallableResultHandler<Boolean> callableHandlerImpl = new CallableResultHandler<Boolean>()
{
public void onCompletion(Boolean resultFromASingleCallable) {
// process result
}
public void onException(ExecutionException executionException) {
// process exception
}
};
AsynchronousCallableCompletionService<Boolean> theDecider =
new AsynchronousCallableCompletionService<Boolean>(
Executors.newFixedThreadPool(NUMBER_OF_THREADS), callableHandlerImpl);
MyAsyncProcessor(List<Callable<Boolean>> districts) {
for (Callable<Boolean> district: districts) {
theDecider.submit(district);
}
}
}
Constructor Summary | |
---|---|
AsynchronousCallableCompletionService(java.util.concurrent.ExecutorService executor,
CallableResultHandler<T> asyncContentLevelCallback)
Instantiates an AsynchronousCallableCompletionService that will use the
provided executor to process Callable s. |
Method Summary | |
---|---|
boolean |
isShutdown()
Whether the service is in a shutdown state. |
boolean |
isTerminated()
Whether the service is in a terminated state. |
void |
shutdownNow(boolean mayInterruptIfRunning)
Cancels all scheduled Callable s including the ones
currently in progress and shuts down the completion service. |
void |
submit(java.util.concurrent.Callable<T> task)
Submits a callable that is to be scheduled with the completion service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AsynchronousCallableCompletionService(java.util.concurrent.ExecutorService executor, CallableResultHandler<T> asyncContentLevelCallback)
AsynchronousCallableCompletionService
that will use the
provided executor
to process Callable
s.
executor
- the executor to be used with the completion serviceasyncContentLevelCallback
- the callback object for processing individual resultsMethod Detail |
---|
public void submit(java.util.concurrent.Callable<T> task)
Callable
terminate without exceptions,
CallableResultHandler#onCompletion(T)
will be called.
Otherwise, CallableResultHandler.onException(ExecutionException)
will be called.
task
- the callable task to be submitted for execution.
RejectedExecutionException
- when service is shut down.public void shutdownNow(boolean mayInterruptIfRunning)
Callable
s including the ones
currently in progress and shuts down the completion service.
The semantics of the cancellation policy for every Future
is the same as the semantics of mayInterruptIfRunning
in Future.cancel(boolean)
. The underlying ExecutorService
is
shut down. A best-effort-only guarantee is made for currently executing tasks.
mayInterruptIfRunning
- Future.cancel(boolean)
,
ExecutorService.shutdownNow()
public boolean isShutdown()
true
, if the service is shut down.ExecutorService.isShutdown()
public boolean isTerminated()
shutdownNow(boolean)
true
if the service is terminated.ExecutorService.isShutdown()
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.4.0) E13403-05 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |