Skip to content
Search

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

References


  1. Aroundck.tistory.com_-_java_executor.pdf ↩

author Zer0 sitemap