mending3
02/14/2021, 12:53 PMThread()
vs Kotlin coroutines?Animesh Sahu
02/14/2021, 1:44 PMThread
may cause slowdown as it needs ~500KB of memory to be allocated as stack, and everytime it destructs it needs to free it down.
Whereas if you have things like spawned thread, blocks forever till request is received or so, and then do some work, or even if it is not regularly created, it may be better, because you free up the threads automatically as they're completed.mending3
02/14/2021, 1:50 PMAnimesh Sahu
02/14/2021, 1:52 PMThreads
are all ok, because that's what being used behing the coroutines for them to run on, but they attach a event loop which make them sleep when not in use and reuse them.Animesh Sahu
02/14/2021, 1:52 PMmending3
02/14/2021, 2:06 PM