545 |
|
* Memory ordering relies mainly on VarHandles. This can be |
546 |
|
* awkward and ugly, but also reflects the need to control |
547 |
|
* outcomes across the unusual cases that arise in very racy code |
548 |
< |
* with very few invariants. So these explicit checks would exist |
549 |
< |
* in some form anyway. All fields are read into locals before |
550 |
< |
* use, and null-checked if they are references. This is usually |
551 |
< |
* done in a "C"-like style of listing declarations at the heads |
552 |
< |
* of methods or blocks, and using inline assignments on first |
553 |
< |
* encounter. Nearly all explicit checks lead to bypass/return, |
554 |
< |
* not exception throws, because they may legitimately arise due |
555 |
< |
* to cancellation/revocation during shutdown. |
548 |
> |
* with very few invariants. All fields are read into locals |
549 |
> |
* before use, and null-checked if they are references. This is |
550 |
> |
* usually done in a "C"-like style of listing declarations at the |
551 |
> |
* heads of methods or blocks, and using inline assignments on |
552 |
> |
* first encounter. Nearly all explicit checks lead to |
553 |
> |
* bypass/return, not exception throws, because they may |
554 |
> |
* legitimately arise due to cancellation/revocation during |
555 |
> |
* shutdown. |
556 |
|
* |
557 |
|
* There is a lot of representation-level coupling among classes |
558 |
|
* ForkJoinPool, ForkJoinWorkerThread, and ForkJoinTask. The |
2113 |
|
/** |
2114 |
|
* Creates a {@code ForkJoinPool} with parallelism equal to {@link |
2115 |
|
* java.lang.Runtime#availableProcessors}, using defaults for all |
2116 |
< |
* other parameters. |
2116 |
> |
* other parameters (see {@link #ForkJoinPool(int, |
2117 |
> |
* ForkJoinWorkerThreadFactory, UncaughtExceptionHandler, boolean, |
2118 |
> |
* int, int, int, Predicate, long, TimeUnit)}). |
2119 |
> |
* |
2120 |
|
* |
2121 |
|
* @throws SecurityException if a security manager exists and |
2122 |
|
* the caller is not permitted to modify threads |
2131 |
|
|
2132 |
|
/** |
2133 |
|
* Creates a {@code ForkJoinPool} with the indicated parallelism |
2134 |
< |
* level, using defaults for all other parameters. |
2134 |
> |
* level, using defaults for all other parameters (see {@link |
2135 |
> |
* #ForkJoinPool(int, ForkJoinWorkerThreadFactory, |
2136 |
> |
* UncaughtExceptionHandler, boolean, int, int, int, Predicate, |
2137 |
> |
* long, TimeUnit)}). |
2138 |
|
* |
2139 |
|
* @param parallelism the parallelism level |
2140 |
|
* @throws IllegalArgumentException if parallelism less than or |
2151 |
|
|
2152 |
|
/** |
2153 |
|
* Creates a {@code ForkJoinPool} with the given parameters (using |
2154 |
< |
* defaults for others). |
2154 |
> |
* defaults for others -- see {@link #ForkJoinPool(int, |
2155 |
> |
* ForkJoinWorkerThreadFactory, UncaughtExceptionHandler, boolean, |
2156 |
> |
* int, int, int, Predicate, long, TimeUnit)}). |
2157 |
|
* |
2158 |
|
* @param parallelism the parallelism level. For default value, |
2159 |
|
* use {@link java.lang.Runtime#availableProcessors}. |
2217 |
|
* different threads may overlap, and may be managed by the given |
2218 |
|
* thread factory, this value may be transiently exceeded.) To |
2219 |
|
* arrange the same value as is used by default for the common |
2220 |
< |
* pool, use {@code 256} plus the parallelism level. Using a value |
2221 |
< |
* (for example {@code Integer.MAX_VALUE}) larger than the |
2222 |
< |
* implementation's total thread limit has the same effect as |
2223 |
< |
* using this limit (which is the default). |
2220 |
> |
* pool, use {@code 256} plus the {@code parallelism} level. (By |
2221 |
> |
* default, the common pool allows a maximum of 256 spare |
2222 |
> |
* threads.) Using a value (for example {@code |
2223 |
> |
* Integer.MAX_VALUE}) larger than the implementation's total |
2224 |
> |
* thread limit has the same effect as using this limit (which is |
2225 |
> |
* the default). |
2226 |
|
* |
2227 |
|
* @param minimumRunnable the minimum allowed number of core |
2228 |
|
* threads not blocked by a join or {@link ManagedBlocker}. To |