We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following is from the Kotlin coroutine docs:
Coroutines ARE light-weight Run the following code: import kotlinx.coroutines.* fun main() = runBlocking { repeat(100_000) { // launch a lot of coroutines launch { delay(1000L) print(".") } } } It launches 100K coroutines and, after a second, each coroutine prints a dot. Now, try that with threads. What would happen? (Most likely your code will produce some sort of out-of-memory error)
Coroutines ARE light-weight
Run the following code:
import kotlinx.coroutines.*
fun main() = runBlocking { repeat(100_000) { // launch a lot of coroutines launch { delay(1000L) print(".") } } }
It launches 100K coroutines and, after a second, each coroutine prints a dot.
Now, try that with threads. What would happen? (Most likely your code will produce some sort of out-of-memory error)
What happens is that it does not crash. (I'm using MacOS 10.15.5 on a 2020 13" MacBook Pro.)
The delay and/or coroutine count should be increased in the example code.
The text was updated successfully, but these errors were encountered:
See explanation here: https://medium.com/@elizarov/such-concurrency-many-threads-wow-7c81ba9e9ebe The example needs to be updated.
Sorry, something went wrong.
Increase timeout in the example to make sure it fails with threads
0b257d7
Fixes #2135
8486907
5705372
Increase timeout in the example to make sure it fails with threads (K…
8d522c5
…otlin#2141) Fixes Kotlin#2135
elizarov
No branches or pull requests
The following is from the Kotlin coroutine docs:
What happens is that it does not crash. (I'm using MacOS 10.15.5 on a 2020 13" MacBook Pro.)
The delay and/or coroutine count should be increased in the example code.
The text was updated successfully, but these errors were encountered: