public final class ConcurrentConfig
extends Object
Central configuration for Groovy's concurrent and parallel features.
Configuration is resolved in order:
groovy.concurrent.poolsize,
groovy.concurrent.virtual)
Inspired by GPars' GParsConfig and PoolUtils, modernised
for virtual threads and the Pool abstraction.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static int |
getDefaultParallelism()Returns the default parallelism level. |
|
public static Pool |
getDefaultPool()Returns the global default pool. |
|
public static boolean |
preferVirtualThreads()Returns true if virtual threads should be preferred. |
|
public static void |
setDefaultParallelism(int size)Sets the default parallelism level programmatically. |
|
public static void |
setDefaultPool(Pool pool)Sets the global default pool. |
Returns the default parallelism level.
Checks (in order): programmatic override, system property
groovy.concurrent.poolsize, then
Runtime.availableProcessors() + 1 (following the GPars convention).
Returns the global default pool. If none has been set, creates one
based on current configuration: a virtual-thread pool if
preferVirtualThreads() is true, otherwise a
fixed pool sized by getDefaultParallelism().
null Returns true if virtual threads should be preferred.
Checks the system property groovy.concurrent.virtual
(default: true on JDK 21+, false otherwise).
Sets the default parallelism level programmatically.
Pass 0 or a negative value to reset to the default.
size - the pool size, or ≤ 0 to reset Sets the global default pool. Pass null to reset.
pool - the pool to use as default, or null to reset