71 |
|
* grow and shrink dynamically. A work-stealing pool makes no |
72 |
|
* guarantees about the order in which submitted tasks are |
73 |
|
* executed. |
74 |
< |
* |
75 |
< |
* @param parallelism the targeted parallelism level |
74 |
> |
* |
75 |
> |
* @param parallelism the targeted parallelism level |
76 |
|
* @return the newly created thread pool |
77 |
|
* @throws IllegalArgumentException if {@code parallelism <= 0} |
78 |
|
* @since 1.8 |
80 |
|
public static ExecutorService newWorkStealingPool(int parallelism) { |
81 |
|
return new ForkJoinPool |
82 |
|
(parallelism, |
83 |
< |
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
83 |
> |
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
84 |
|
null, true); |
85 |
|
} |
86 |
|
|
87 |
|
/** |
88 |
< |
* Creates a work-stealing thread pool using all |
88 |
> |
* Creates a work-stealing thread pool using all |
89 |
|
* (@link Runtime#availableProcessors available processors} |
90 |
|
* as its target parallelism level. |
91 |
|
* @return the newly created thread pool |
94 |
|
public static ExecutorService newWorkStealingPool() { |
95 |
|
return new ForkJoinPool |
96 |
|
(Runtime.getRuntime().availableProcessors(), |
97 |
< |
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
97 |
> |
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
98 |
|
null, true); |
99 |
|
} |
100 |
|
|