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




Latest Courses