Javatpoint Logo
Javatpoint Logo

Java Forkjoinpool awaitTermination() Method

The awaitTermination() method of ForkJoinPool class is used to await the termination after the shutdown request or the timeout specified as the parameter. The timeout elapses until the program shut down. When It is called with common-pool, It acts as the awaitQuiescence() method. It returns true if executor terminate and false if the time specified as timeout elapses.

Syntax:

Parameter:

timeout - the time to wait

unit - the time unit of the timeout argument this can be HOUR, SECONDS, DAY, etc.

Returns:

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

Throws

InterruptedException

Example 1

Test it Now

Output:

numbers of core available in your processor:4
Before awaitTermination (is terminated):false
is awaitQuiescent :true
After awaitTermination (is terminated):false
Pool.invoke :161

Example 2

Test it Now

Output:

numbers of core available in your processor:4
  is terminated :false





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials