We break down three “anti-progress” states in concurrent Kotlin coroutine code:
deadlock (mutual waiting),
livelock (busy motion with no result), and
starvation (tasks getting “starved” of CPU/time/locks). Using examples with
Mutex,
withLock, and
tryLock(), we show how bugs are born from lock acquisition order, overly long critical sections, and “polite” retries—and then we fix it with rules: a single ordering by
id, short
withLock, backoff, and (when possible) a move to
confinement/
actor design.