Quiz: Shared State
Test yourself on what you've learned about shared state, coarse-grained thread confinement, deadlocks, mutex, and dispatchers.
We'll cover the following...
We'll cover the following...
Technical Quiz
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
1 / 5