ForkJoinPool.this
- this()
- this(int parallelism)
- this(int parallelism, ForkJoinWorkerThreadFactory factory, UncaughtExceptionHandler handler, bool asyncMode)
- this(int parallelism, ForkJoinWorkerThreadFactory factory, UncaughtExceptionHandler handler, bool asyncMode, int corePoolSize, int maximumPoolSize, int minimumRunnable, Predicate!(ForkJoinPool) saturate, Duration keepAliveTime)
hunt concurrency ForkJoinPool ForkJoinPool
constructorsfunctionsstatic functionsstatic variablesvariables
Creates a {@code ForkJoinPool} with the given parameters.
@param parallelism the parallelism level. For default value, use {@link java.lang.Runtime#availableProcessors}.
@param factory the factory for creating new threads. For default value, use {@link #defaultForkJoinWorkerThreadFactory}.
@param handler the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks. For default value, use {@code null}.
@param asyncMode if true, establishes local first-in-first-out scheduling mode for forked tasks that are never joined. This mode may be more appropriate than default locally stack-based mode in applications in which worker threads only process event-style asynchronous tasks. For default value, use {@code false}.
@param corePoolSize the number of threads to keep in the pool (unless timed out after an elapsed keep-alive). Normally (and by default) this is the same value as the parallelism level, but may be set to a larger value to reduce dynamic overhead if tasks regularly block. Using a smaller value (for example {@code 0}) has the same effect as the default.
@param maximumPoolSize the maximum number of threads allowed. When the maximum is reached, attempts to replace blocked threads fail. (However, because creation and termination of different threads may overlap, and may be managed by the given thread factory, this value may be transiently exceeded.) To arrange the same value as is used by default for the common pool, use {@code 256} plus the {@code parallelism} level. (By default, the common pool allows a maximum of 256 spare threads.) Using a value (for example {@code Integer.MAX_VALUE}) larger than the implementation's total thread limit has the same effect as using this limit (which is the default).
@param minimumRunnable the minimum allowed number of core threads not blocked by a join or {@link ManagedBlocker}. To ensure progress, when too few unblocked threads exist and unexecuted tasks may exist, new threads are constructed, up to the given maximumPoolSize. For the default value, use {@code 1}, that ensures liveness. A larger value might improve throughput in the presence of blocked activities, but might not, due to increased overhead. A value of zero may be acceptable when submitted tasks cannot have dependencies requiring additional threads.
@param saturate if non-null, a predicate invoked upon attempts to create more than the maximum total allowed threads. By default, when a thread is about to block on a join or {@link ManagedBlocker}, but cannot be replaced because the maximumPoolSize would be exceeded, a {@link RejectedExecutionException} is thrown. But if this predicate returns {@code true}, then no exception is thrown, so the pool continues to operate with fewer than the target number of runnable threads, which might not ensure progress.
@param keepAliveTime the elapsed time since last use before a thread is terminated (and then later replaced if needed). For the default value, use {@code 60, TimeUnit.SECONDS}.
@param unit the time unit for the {@code keepAliveTime} argument
@throws IllegalArgumentException if parallelism is less than or equal to zero, or is greater than implementation limit, or if maximumPoolSize is less than parallelism, of if the keepAliveTime is less than or equal to zero. @throws NullPointerException if the factory is null @throws SecurityException if a security manager exists and the caller is not permitted to modify threads because it does not hold {@link java.lang.RuntimePermission}{@code ("modifyThread")}