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

coder82

08/26/2019, 8:16 AM
Question for the coroutine masters. I found this code in the coroutine library and I asked myself, in which context is this block running on. I gave myself an answer: "In whatever context withTimeout is called". So If i run this in a runBlocking ran from main thread, the timeout block will still run on main thread. What do you reckon? Furthermore since withTimeout doesn't have a context parameter, if I want to run it into another context, then I need to include it into another coroutine builder which accepts context, subsequently withTimout will run on that same context.
o

octylFractal

08/26/2019, 8:18 AM
yes, it will inherit the context of the parent function, if you want a different context, use
withContext
either around or inside
👍 1
4 Views