I remember from somewhere that putting a loop insi...
# coroutines
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?
In general, that’s not a bad idea. I’ve written and seen lots of coroutines with loops.
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?
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
ah I see
A bit late to the show, but there's an excellent thread about it here: https://kotlinlang.slack.com/archives/C1CFAFJSK/p1608417755332100