Quiz: Shared State
Test yourself on what you've learned about shared state, coarse-grained thread confinement, deadlocks, mutex, and dispatchers.
1
(Fill in the blank.) The value of the counter in the following code snippet is ________.
fun main() = runBlocking {
massiveRun {
counter++
}
println(counter)
}
suspend fun massiveRun(action: suspend () -> Unit) =
withContext(Dispatchers.Default) {
repeat(1000) {
launch {
repeat(1000) { action() }
}
}
}
A)
less than 1,000,000
B)
less than 100,000
C)
1,000,000
D)
100,000
Question 1 of 50 attempted
Get hands-on with 1400+ tech skills courses.