Javatpoint Logo
Javatpoint Logo

Java ThreadPoolExecutor toString() Method

The toString() method of ThreadPoolExecutor class returns the string representation of the ThreadPoolExecutor object.

Syntax

Parameters

NA

Return

A string identifying this pool, as well as its state

Throw

Does not throw the exception.

Example 1

Test it Now

Output:

toString :java.util.concurrent.ThreadPoolExecutor@33909752[Shutting down, pool size = 2, active threads = 2, queued tasks = 0, completed tasks = 0]
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
 toString :java.util.concurrent.ThreadPoolExecutor@55f96302[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]






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