Junior — Senior
What will happen to the variable when multiple coroutines are run?
livecode
Task condition
Determine what result will be printed to the console after executing the following code:
val scope = CoroutineScope(Dispatchers.Default + SupervisorJob())
var i = 0
fun main() = runBlocking {
repeat(100000) {
increase()
}
println(i)
}
fun increase() = scope.launch {
synchronized(this) {
i++
}
}