Package: groovy.concurrent

## [Java] Class ConcurrentConfig

- groovy.concurrent.ConcurrentConfig

-     public final class ConcurrentConfig
      extends Object

  Central configuration for Groovy's concurrent and parallel features.

  Configuration is resolved in order:

  1. Programmatic overrides via setter methods
  2. System properties (`groovy.concurrent.poolsize`, `groovy.concurrent.virtual`)
  3. Sensible defaults (processors + 1, virtual threads on JDK 21+)

  Inspired by GPars' `GParsConfig` and `PoolUtils`, modernised for virtual threads and the Pool abstraction.

  See Also:
    Pool
  Since:
    6.0.0

- - ### Methods Summary

    Methods
    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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public static int getDefaultParallelism()

      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 default pool size, always > 0

    - #### public static Pool getDefaultPool()

      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().

      Returns:
        the default pool, never `null`

    - #### public static boolean preferVirtualThreads()

      Returns `true` if virtual threads should be preferred.

      Checks the system property `groovy.concurrent.virtual` (default: `true` on JDK 21+, `false` otherwise).

      Returns:
        whether to prefer virtual threads

    - #### public static void setDefaultParallelism(int size)

      Sets the default parallelism level programmatically. Pass `0` or a negative value to reset to the default.

      Parameters:
        `size` - the pool size, or ≤ 0 to reset

    - #### public static void setDefaultPool(Pool pool)

      Sets the global default pool. Pass `null` to reset.

      Parameters:
        `pool` - the pool to use as default, or `null` to reset