Skip to content

Commit 1500fe7

Browse files
qwwdfsadrecheej
authored andcommitted
Clarify documentation for IO dispatcher (Kotlin#2286)
Fixes Kotlin#2272
1 parent 7de232f commit 1500fe7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kotlinx-coroutines-core/jvm/src/Dispatchers.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public actual object Dispatchers {
9797
* The [CoroutineDispatcher] that is designed for offloading blocking IO tasks to a shared pool of threads.
9898
*
9999
* Additional threads in this pool are created and are shutdown on demand.
100-
* The number of threads used by this dispatcher is limited by the value of
100+
* The number of threads used by tasks in this dispatcher is limited by the value of
101101
* "`kotlinx.coroutines.io.parallelism`" ([IO_PARALLELISM_PROPERTY_NAME]) system property.
102102
* It defaults to the limit of 64 threads or the number of cores (whichever is larger).
103103
*
@@ -106,9 +106,13 @@ public actual object Dispatchers {
106106
* If you need a higher number of parallel threads,
107107
* you should use a custom dispatcher backed by your own thread pool.
108108
*
109+
* ### Implementation note
110+
*
109111
* This dispatcher shares threads with a [Default][Dispatchers.Default] dispatcher, so using
110112
* `withContext(Dispatchers.IO) { ... }` does not lead to an actual switching to another thread —
111113
* typically execution continues in the same thread.
114+
* As a result of thread sharing, more than 64 (default parallelism) threads can be created (but not used)
115+
* during operations over IO dispatcher.
112116
*/
113117
@JvmStatic
114118
public val IO: CoroutineDispatcher = DefaultScheduler.IO

0 commit comments

Comments
 (0)