dispatcher in kotlin coroutine code example
Example: kotlin coroutine dispatcher
Dispatchers.Default - Different thread (if possible)
It is backed by a shared pool of threads on JVM.
Dispatchers.Main - Platform specific main thread
(if exists).
Dispatchers.IO - Thread designed for offloading
blocking IO tasks to a shared pool of threads.
Dispatchers.Unconfined - Always uses first
available thread (most performant dispatcher).
newSingleThreadContext - Creates a new coroutine
execution context using a single thread with built-in yield
support.
newFixedThreadPoolContext - Creates new
coroutine execution context with the fixed-size
thread-pool and built-in yield support.