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

Gopal S Akshintala

08/23/2020, 5:49 AM
A Noob question, when I print
Thread.currentThread().name
, what exactly does
@coroutine#id
indicate (I understand it's an identifier to coroutine, but what exact piece of work does it indicate)? Is it the work the current thread does from one suspension point to till it encounters another suspension point? What exactly is a
@coroutine#id
physically translates to?
o

octylFractal

08/23/2020, 5:51 AM
coroutines have an
CoroutineName
element that is attached to the current thread name when the debug sys prop is enabled when unspecified it is incremented from the name of the parent., or
coroutine
if there is none
g

Gopal S Akshintala

08/23/2020, 5:52 AM
Yes, I get it it's an identifier to coroutine, but my question is what piece of work does it indicate? When will it be incremented?
o

octylFractal

08/23/2020, 6:04 AM
the ID is incremented as part of
newCoroutineContext
, so
coroutineScope
and
withContext
do not increment the ID, but
launch
and
async
, etc. any concurrency will
g

Gopal S Akshintala

08/23/2020, 6:14 AM
Thanks @octylFractal 🙂
4 Views