Javatpoint Logo
Javatpoint Logo

Java ThreadPool Executor awaitTermination() Method

The awaitTermination() method of ThreadPoolExecutor class blocks until tasks in the thread pool completes the execution or time for execution elapses.

Syntax

Parameter

timeout - the maximum time to wait

unit - the time unit of the timeout argument

Returns

True if this executor terminated and false if the timeout elapsed before termination

Throw

InterruptedException - if interrupted while waiting

Example 1

Test it Now

Output:

creating service
await termination for thread:pool-1-thread-1
null

Example 2

Test it Now

Output:

allowCoreThreadTimeOut  is already true
In Runnable!






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA