File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed
kotlinx-coroutines-core/jvm/test/guide Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ resource inside the block that needs closing or release outside of the block.
381381
382382For example, here we imitate a closeable resource with the ` Resource ` class that simply keeps track of how many times
383383it was created by incrementing the ` acquired ` counter and decrementing the counter in its ` close ` function.
384- Now let us let us create a lot of coroutines, each of which creates a ` Resource ` at the end of the ` withTimeout ` block
384+ Now let us create a lot of coroutines, each of which creates a ` Resource ` at the end of the ` withTimeout ` block
385385and releases the resource outside the block. We add a small delay so that it is more likely that the timeout occurs
386386right when the ` withTimeout ` block is already finished, which will cause a resource leak.
387387
@@ -398,7 +398,7 @@ class Resource {
398398
399399fun main () {
400400 runBlocking {
401- repeat(100_000 ) { // Launch 100K coroutines
401+ repeat(10_000 ) { // Launch 10K coroutines
402402 launch {
403403 val resource = withTimeout(60 ) { // Timeout of 60 ms
404404 delay(50 ) // Delay for 50 ms
@@ -446,7 +446,7 @@ class Resource {
446446fun main () {
447447// sampleStart
448448 runBlocking {
449- repeat(100_000 ) { // Launch 100K coroutines
449+ repeat(10_000 ) { // Launch 10K coroutines
450450 launch {
451451 var resource: Resource ? = null // Not acquired yet
452452 try {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class Resource {
1616
1717fun main () {
1818 runBlocking {
19- repeat(100_000 ) { // Launch 100K coroutines
19+ repeat(10_000 ) { // Launch 10K coroutines
2020 launch {
2121 val resource = withTimeout(60 ) { // Timeout of 60 ms
2222 delay(50 ) // Delay for 50 ms
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class Resource {
1616
1717fun main () {
1818 runBlocking {
19- repeat(100_000 ) { // Launch 100K coroutines
19+ repeat(10_000 ) { // Launch 10K coroutines
2020 launch {
2121 var resource: Resource ? = null // Not acquired yet
2222 try {
You can’t perform that action at this time.
0 commit comments