The official document about runBlokcing says
Runs a new coroutine and blocks the current thread until its completion. This function should not be used from a coroutine. It is designed to bridge regular blocking code to libraries that are written in suspending style, to be used in main functions and in tests.
I think it means that runBlocking
blocks only current thread.
but the Kotlin Coroutines Deep Dive
by written Marcin Moskała
.
In the book, it says
"Using a dispatcher, we can make runBlocking run on a different thread. But still, the thread on which this builder has been started will be blocked until the coroutines is done."
I understood it even if i change the current thread to worker(or other) thread with withContext
or something and run the 'runBlocking' in the worker thread, the runBlocking
will still block all the thread including main thread.
Therefore, what i want to know is runBlocking
always block the main thread no matter what ways i use?