Created
May 14, 2022 14:16
-
-
Save enginebai/ba56161217d78c32880113a44427b4ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Worker { | |
var total = 0 | |
fun accumulate() { | |
for (i = 0; i < 10000; i++) { | |
total = total + 1 | |
} | |
} | |
fun doWork() { | |
for (j = 1; j <= 5; j++) { | |
val t = thread { | |
accumulate() | |
} | |
} | |
} | |
} | |
fun main() { | |
Worker.doWork() | |
println(Woker.total) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment