문제점

동기화 블로킹

fun main() = runBlocking {
    val lock = Any()
    massiveRun {
        syncronized(lock) { // 스레드를 블로킹함
            counter++
        }
    }
}

원자성

private var counter = AtomicInteger()

fun main() = runBlocking {
    massiveRun {
        counter.incrementAndGet()
    }
}
private val users = AtomicReference(listOf<User>())

suspend fun fetchUser(id: Int) {
    val newUser = api.fetchUser(id)
    users.getAndUpdate { it + newUser }
}

싱글스레드로 제한된 디스패처