File tree 3 files changed +5
-5
lines changed
kotlinx-coroutines-core/jvm/test/guide
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.
381
381
382
382
For example, here we imitate a closeable resource with the ` Resource ` class that simply keeps track of how many times
383
383
it 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
385
385
and releases the resource outside the block. We add a small delay so that it is more likely that the timeout occurs
386
386
right when the ` withTimeout ` block is already finished, which will cause a resource leak.
387
387
@@ -398,7 +398,7 @@ class Resource {
398
398
399
399
fun main () {
400
400
runBlocking {
401
- repeat(100_000 ) { // Launch 100K coroutines
401
+ repeat(10_000 ) { // Launch 10K coroutines
402
402
launch {
403
403
val resource = withTimeout(60 ) { // Timeout of 60 ms
404
404
delay(50 ) // Delay for 50 ms
@@ -446,7 +446,7 @@ class Resource {
446
446
fun main () {
447
447
// sampleStart
448
448
runBlocking {
449
- repeat(100_000 ) { // Launch 100K coroutines
449
+ repeat(10_000 ) { // Launch 10K coroutines
450
450
launch {
451
451
var resource: Resource ? = null // Not acquired yet
452
452
try {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class Resource {
16
16
17
17
fun main () {
18
18
runBlocking {
19
- repeat(100_000 ) { // Launch 100K coroutines
19
+ repeat(10_000 ) { // Launch 10K coroutines
20
20
launch {
21
21
val resource = withTimeout(60 ) { // Timeout of 60 ms
22
22
delay(50 ) // Delay for 50 ms
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class Resource {
16
16
17
17
fun main () {
18
18
runBlocking {
19
- repeat(100_000 ) { // Launch 100K coroutines
19
+ repeat(10_000 ) { // Launch 10K coroutines
20
20
launch {
21
21
var resource: Resource ? = null // Not acquired yet
22
22
try {
You can’t perform that action at this time.
0 commit comments