public class CommonPool
extends CoroutineDispatcher
Represents common pool of shared threads as coroutine dispatcher for compute-intensive tasks.
If there isn't a SecurityManager present it uses java.util.concurrent.ForkJoinPool when available, which implements
efficient work-stealing algorithm for its queues, so every coroutine resumption is dispatched as a separate task even
when it already executes inside the pool. When available, it wraps ForkJoinPool.commonPool and provides a similar
shared pool where not.
If there is a SecurityManager present (as would be if running inside a Java Web Start context) then a plain thread pool is created. This is to work around the fact that ForkJoinPool creates threads that cannot perform privileged actions.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_PARALLELISM_PROPERTY_NAME
Name of the property that controls default parallelism level of
class CommonPool.
If the property is not specified, Runtime.getRuntime().availableProcessors() - 1 will be used instead (or 1 for single-core JVM).
Note that until Java 10, if an application is run within a container,
Runtime.getRuntime().availableProcessors() is not aware of container constraints and will return the real number of cores. |
static CommonPool |
INSTANCE
Represents common pool of shared threads as coroutine dispatcher for compute-intensive tasks.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispatch(kotlin.coroutines.experimental.CoroutineContext context,
java.lang.Runnable block)
Dispatches execution of a runnable block onto another thread in the given context.
|
java.lang.String |
toString() |
dispatch, interceptContinuation, isDispatchNeeded, toStringpublic static java.lang.String DEFAULT_PARALLELISM_PROPERTY_NAME
Name of the property that controls default parallelism level of class CommonPool.
If the property is not specified, Runtime.getRuntime().availableProcessors() - 1 will be used instead (or 1 for single-core JVM).
Note that until Java 10, if an application is run within a container,
Runtime.getRuntime().availableProcessors() is not aware of container constraints and will return the real number of cores.
class CommonPoolpublic static CommonPool INSTANCE
Represents common pool of shared threads as coroutine dispatcher for compute-intensive tasks.
If there isn't a SecurityManager present it uses java.util.concurrent.ForkJoinPool when available, which implements
efficient work-stealing algorithm for its queues, so every coroutine resumption is dispatched as a separate task even
when it already executes inside the pool. When available, it wraps ForkJoinPool.commonPool and provides a similar
shared pool where not.
If there is a SecurityManager present (as would be if running inside a Java Web Start context) then a plain thread pool is created. This is to work around the fact that ForkJoinPool creates threads that cannot perform privileged actions.