Rainer Schlonvoigt
08/12/2019, 1:20 PMDominaezzz
08/12/2019, 1:22 PMRainer Schlonvoigt
08/12/2019, 1:24 PMDominaezzz
08/12/2019, 1:25 PMDispatchers.Main
?Dispatchers.Default
, <http://Dispatchers.IO|Dispatchers.IO>
and custom dispatchers if you see fit.Rainer Schlonvoigt
08/12/2019, 1:30 PMlouiscad
08/12/2019, 2:38 PMmain
function, you can just start it that way:
suspend fun main(): Unit = coroutineScope {
// app starts here, launch coroutines and all
}
Dominaezzz
08/12/2019, 2:49 PMrunBlocking
, right?louiscad
08/12/2019, 2:56 PMsuspend fun main
uses Dispatchers.Default
in its coroutineContext
, which is multi-threaded (at least 2 threads, configured for number of CPU cores), while runBlocking
reuses the JVM single initial thread.Dominaezzz
08/12/2019, 3:09 PMfun main() = runBlocking(Dispatchers.Default) {
// stuff
}
louiscad
08/12/2019, 3:40 PMsuspend fun main
inject/reuse the JVM initial thread into Dispatchers.Default
? If not, is it possible without major drawbacks?elizarov
08/12/2019, 5:30 PMDico
08/12/2019, 5:38 PMlouiscad
08/12/2019, 6:36 PMDico
08/12/2019, 10:24 PMlouiscad
08/12/2019, 10:43 PMsuspend fun main
does result in a multi-threaded coroutineContext regardless.