I remember from somewhere that putting a loop insi...
# coroutines
w
I remember from somewhere that putting a loop inside of a coroutine is a pretty bad idea but I cant remember why. Could someone please explain why?
z
In general, that’s not a bad idea. I’ve written and seen lots of coroutines with loops.
w
so in theory, if each coroutine launched inside of a loop that doesn't edit some global / shared state and are completely independent of each other then it shouldnt be a problem?
g
If you have an infinite loop in a coroutine, and this loop doesn't have suspend functions inside of it, it will block current thread (because it will not allow other code to run on this thread), but it's a programming error rather than some issue with loops in coroutines
w
ah I see
b
A bit late to the show, but there's an excellent thread about it here: https://kotlinlang.slack.com/archives/C1CFAFJSK/p1608417755332100