Javatpoint Logo
Javatpoint Logo

Java Executor newWorkStealingPool() Method

The newWorkStealingPool() method of Executors class creates a work-stealing thread pool using the number of available processors as its target parallelism level.

Syntax

Parameter

parallelism - the targeted parallelism level

Returns

the newly created thread pool

Throw

IllegalArgumentException

Example 1

Test it Now

Output:

size of mypool: 0
Thread Name: ForkJoinPool-1-worker-5
after sleep Thread Name: ForkJoinPool-1-worker-5
Thread Name: ForkJoinPool-1-worker-3
after sleep Thread Name: ForkJoinPool-1-worker-3
Total number threads scheduled): 0

Example 1

Test it Now

Output:

size of mypool: 0
Thread Name: ForkJoinPool-1-worker-5
after sleep Thread Name: ForkJoinPool-1-worker-5
Thread Name: ForkJoinPool-1-worker-3
after sleep Thread Name: ForkJoinPool-1-worker-3
Total number threads scheduled): 0
Next TopicJava Executors





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