Skip to content

Commit

Permalink
Increase timeout in the example to make sure it fails with threads (K…
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov committed Jul 16, 2020
1 parent b7d6518 commit 5705372
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ import kotlinx.coroutines.*
fun main() = runBlocking {
repeat(100_000) { // launch a lot of coroutines
launch {
delay(1000L)
delay(5000L)
print(".")
}
}
Expand All @@ -351,7 +351,7 @@ fun main() = runBlocking {
<!--- TEST lines.size == 1 && lines[0] == ".".repeat(100_000) -->

It launches 100K coroutines and, after a second, each coroutine prints a dot.
It launches 100K coroutines and, after 5 seconds, 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)

Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/jvm/test/guide/example-basic-08.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.coroutines.*
fun main() = runBlocking {
repeat(100_000) { // launch a lot of coroutines
launch {
delay(1000L)
delay(5000L)
print(".")
}
}
Expand Down

0 comments on commit 5705372

Please sign in to comment.