Loading lesson…
Level 1 · Apprentice0 XP
Coordinate coroutines safely: confine state, lock briefly, or pass messages.
Step 1 / 5
Problem1,000 coroutines on Dispatchers.Default each do counter++. The result is 943, not 1,000, and different every run.
← → step
Before this: Coroutines: cancellation, errors and dispatchers
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Reproduce the lost-increment race with 1,000 coroutines, fix it three ways (Mutex, AtomicInteger, single-threaded confinement), and build a worker pool with a Channel that processes 10,000 jobs with 4 workers.