Aller au contenu

Busy Loop In Coroutine (ARCH8033)

Ce contenu n’est pas encore disponible dans votre langue.

Key kotlin.async.busy-loop-in-coroutine · Severity warning · Category async

Flags a while(true) loop inside launch / async with no delay, yield or suspension - it never lets the dispatcher run anything else.

launch { while (true) { if (ready()) break } }
launch { while (isActive && !ready()) { delay(50) } }

Suspend inside the loop (delay, yield, a channel receive) so the thread is released.