An object that executes submitted Runnable tasks. This interface provides a way of decoupling task submission from the mechanics of how each task will be run, including details of thread use, scheduling, etc. An Executor is normally used instead of explicitly creating threads.
- This interface provides a way of decoupling task submission from the mechanics of how each will be run, including details of thread use, scheduling etc.
- An Executor is normally use instead of explicitly creating threads.
- Rather than new Thread(new RunnableTask()).start() for each of a set of tasks, might be use
executor.execute(new RunnableTask1())
executor.execute(new RunnableTask1())
….
ExecutorService (interface | java.util.concurrent.ExecutorService, implements Executor | direct subclasses AbstractExecutorService, ForkJoinPool, ScheduledExecutorService, ScheduledThreadPoolExecutor, ThreadPoolExecutor)
- An Executor that provides methods to manage termination and methods that can produce a Future tracking process one or more asynchronous tasks.
- An ExecutorService can be shut down, which will cause it to reject new tasks.
- shutdown() method allow to shutting down previously submitted task before termination.
- shutdownNow() method prevents waiting tasks from starting and attempts to stop currently executing task.
- A shutdown ExecutorService, no new task can be submitted, an unused ExecutorService should be shut down (to allow reclamation of its resources).
- Method submit() extends base method execute() by creating and returning a Future that can be use to cancel execution and/or wait completion.
- Method invokeAny and invokeAll perform the most commonly useful form of bulk execution
- The Executors class provides factory methods-.
- A Future represents the result of an asynchronous computation.
- The result can only retrieve with method get when computation has completed.
- Cancellation is performed by cancel method.
- Once a computation has completed, computation can’t be cancelled.
- The FutureTask class is an implementation of Future that implements Runnable, so may be executed by an executor.
newFixedThreadPoots(int)
Future (interface | java.util.concurrent.Future<V> | direct subclass CompletableFuture<T>, CountedCompleter<T>, ForkJoinTask<V>, FutureTask<V>, RecursiveAction, RecursiveTask<V>, RunnableFuture<V>, RunnableScheduledFuture<V>, ScheduledFuture<V>)
- A Future represents the result of an asynchronous computation.
- The result can only retrieve with method get when computation has completed.
- Cancellation is performed by cancel method.
- Once a computation has completed, computation can’t be cancelled.
- The FutureTask class is an implementation of Future that implements Runnable, so may be executed by an executor.
Comments
Post a Comment