https://kotlinlang.org logo
#coroutines
Title
# coroutines
b

Brian Carbone

01/02/2020, 3:26 PM
how do you create a coroutine scope for the main thread when you're not using Android? there's no Dispatchers.Main
it's just the jvm
s

streetsofboston

01/02/2020, 3:40 PM
IIRC, you'd need a thread that is part of a pool tied to a queue on which Coroutines are scheduled (in Android that would be called a Looper). A plain main JVM thread does not meet that requirement.
l

louiscad

01/02/2020, 6:59 PM
If you use JavaFx or Java Swing, there's ui integrations for it. Otherwise, you just use
runBlocking { ... }
in the main function.
3 Views