Javatpoint Logo
Javatpoint Logo

Java ThreadPoolExecutor remove() Method

The remove() method of ThreadPoolExecutor class removes this task from the executor's internal queue if it is present, thus causing it not to be run if it has not already started.

Syntax

Parameters

Task - the task to remove

Return

The true if the task was removed

Throw

Does not throw the exception.

Example 1

Test it Now

Output:

Running Thread Name: pool-1-thread-2
Running Thread Name: pool-1-thread-1
Completed Thread Name: pool-1-thread-1
Completed Thread Name: pool-1-thread-2

Example 2

Test it Now

Output:

Starting threads
i=5
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