Java.util.concurrent.ExecutorService
lastmod 2020-01-20created 2014-06-035 edits
ExecutorService
It also supports controlling thread state. Unlike the Furture class, it controls all threads registered with the service at once.
- shutdown()
- shutdownNow()
- awaitTermination(timeout, unit)
shutdown()
The executor service no longer accepts new threads. Threads currently running or already registered keep running normally.
shutdownNow()
Threads waiting to run are canceled and do not run. No new threads are accepted. Throws InterruptException to the currently running threads.
awaitTermination(long timeout, TimeUnit unit)
Does the same work as shutdown, but the current thread blocks until all threads terminate. If time runs out before all threads have terminated, it returns false; if they terminated normally, it returns true.
timeout and TimeUnit together express a single duration.
- ex) TimeUnit .SECOND , TimeUnit.DAYS ...
- ex) awaitTermination(30, TimeUnit .SECOND);
See also
Favorite site
- ExecutorService, the Java thread management class.
- Java Concurrency: Executor and Callable/Future
- Thread pool and hashmap material
- A good post on Java Thread Pool (Object Pool Control)
- Java ThreadPool Api Sample
- Explanation of JAVA ThreadPool
- Implementing a Java Thread Pool
- (Java) Using threads with ExecutorService and Thread
- Android Developer: ExecutorService reference
- Java ThreadPool Api Sample
- Java Thread Pool example
- [Recommended] Java parallel programming: Task execution (explanation of ExecutorService) 1
- Java Concurrency: Executor and Callable/Future
- (Concurrency) - Using awaitTermination() of ExecutorService
- Multithreading example (ExecutorService)
References
-
Aroundck.tistory.com_-_java_executor.pdf ↩
Pages that link here