ScheduleExecutorService extends ExecutorService
ExecutorService manages to submit tasks much better than Executor. It accepts both Runnable and Callable.
ScheduleExecutorService manages to submit tasks and run in planned time slices.
'IsTerminated()': testing if all submitted tasks having been accomplished.
'IsShutDown()': testing if the executor is shut down.
'shutDownNow' means that attempting to halt active running threads, and stop picking up tasks from the queue, and returning un-implemented tasks in a collection. 'shutDownNow' is more like shutting down at once.
Executor consists of a queue and a pool.
Pool types: fixed-sized, single thread, scheduled thread pool, cached thread pool
The 'Executors' is a factory, where a client achieve a specific type of thread pool.
ExecutorService es = Executors.newCachedThreadPool();
es.execute(new PrintNum(10, 66));
es.execute(new PrintNum(10, 20));
es.shutdown();
No comments:
Post a Comment