You can have multiple threads in Kotlin/Native. Each thread can have its own event loop with runBlocking and have number of coroutines running there. Currently communication between those threads via coroutine primitives (like channels) is not supported. This issue it to track enhancement of Kotlin/Native in kotlinx.coroutines library so that all the following becomes possible:
- Launching coroutines from one thread with a dispatcher on another thread
- Await/join coroutine running on another thread
- Send/Receive elements to/from coroutines on other threads
UPDATE: Currently, coroutines are supported only on the main thread. You cannot have coroutines off the main thread due to the way the library is currently structured.
UPDATE 2: the separate library version that supports Kotlin/Native multithreading is released on a regular basis.
For the details and limitations, please follow kotlin-native-sharing.md document.
The latest version: 1.5.2-native-mt
You can have multiple threads in Kotlin/Native.
Each thread can have its own event loop with. Currently communication between those threads via coroutine primitives (like channels) is not supported. This issue it to track enhancement of Kotlin/Native inrunBlockingand have number of coroutines running therekotlinx.coroutineslibrary so that all the following becomes possible:UPDATE: Currently, coroutines are supported only on the main thread. You cannot have coroutines off the main thread due to the way the library is currently structured.
UPDATE 2: the separate library version that supports Kotlin/Native multithreading is released on a regular basis.
For the details and limitations, please follow kotlin-native-sharing.md document.
The latest version:
1.5.2-native-mt