Javatpoint Logo
Javatpoint Logo

Java ThreadPoolExecutor shutdown() Method

The shutdown() method of ThreadPoolExecutor class initiates an orderly shutdown in which already submitted task is accepted, but no new task is accepted.

Syntax

Parameters

NA

Return

NA

Throw

SecurityException

Example 1

Test it Now

Output:

Is Executor is shutdown :false
get Task count after:2
Running Thread Name: pool-1-thread-1
Running Thread Name: pool-1-thread-2
Completed Thread Name: pool-1-thread-1
Completed Thread Name: pool-1-thread-2

Example 2

Test it Now

Output:

Starting threads
  Maximum pool size: 2147483647
get Task count before:0
 Is Executor is shutdown :false
i=5
Threads started, main ends
i=5






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