public final class DefaultPool
extends Object
implements Pool
Default implementation of Pool.
Sized pools (fixed(int), cpu()) use ForkJoinPool for work-stealing and parallel stream isolation. I/O pools (virtual(), io()) use virtual threads on JDK 21+.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public ForkJoinPool |
asForkJoinPool() |
|
public static Pool |
cpu()Creates a pool sized to availableProcessors(), backed by
ForkJoinPool. |
|
public static Pool |
current()Returns the pool bound to the current scope, or null. |
|
public void |
execute(Runnable command) |
|
public static Pool |
fixed(int size)Creates a fixed-size pool backed by ForkJoinPool for work-stealing and parallel stream isolation. |
|
public int |
getActiveCount() |
|
public int |
getPoolSize() |
|
public static Pool |
io()Creates a pool for I/O-bound work. |
|
public void |
shutdown() |
|
public String |
toString() |
|
public boolean |
usesVirtualThreads() |
|
public static Pool |
virtual()Creates a virtual-thread-per-task pool, or a cached daemon pool as fallback on JDK < 21. |
<T> |
public static T |
withCurrent(Pool pool, Supplier<T> supplier)Executes the supplier with the given pool as current. |
Creates a pool sized to availableProcessors(), backed by
ForkJoinPool. Ideal for CPU-bound work and parallel collections.
Returns the pool bound to the current scope, or null.
Creates a fixed-size pool backed by ForkJoinPool for work-stealing and parallel stream isolation.
Creates a pool for I/O-bound work. Uses virtual threads if available, otherwise a fixed pool sized by ConcurrentConfig.getDefaultParallelism.
Creates a virtual-thread-per-task pool, or a cached daemon pool as fallback on JDK < 21.