Join Slack
Powered by
Hey! Does anyone know how to use threads in kotlin...
# kotlin-native
j
jQrgen
07/03/2023, 1:31 PM
Hey! Does anyone know how to use threads in kotlin/native?
c
Chris Lee
07/03/2023, 1:32 PM
Presumably there’s a more relevant question in there somewhere.
https://dontasktoask.com
j
jQrgen
07/03/2023, 1:33 PM
Ehhh..
j
Joel Denke
07/03/2023, 6:03 PM
Not sure I understand what want to know, but no issues using regular JVM threads. I recommend avoid mixing Thread and Coroutines however. It works but easy make mistakes mixing.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.concurrent/thread.html
l
Landry Norris
07/04/2023, 3:47 AM
You can use newSingleThreadContext (
https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/new-single-thread-context.htmlorg/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/new-single-thread-context.html
) to create a coroutine scope backed by a single thread. This method is also multiplatform (except JS).
8
Views
Open in Slack
Previous
Next