File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
kotlinx-coroutines-core/src/test/kotlin/guide Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -533,7 +533,7 @@ Exception in thread "main" java.util.concurrent.CancellationException: Timed out
533
533
<!-- - TEST STARTS_WITH -->
534
534
535
535
We have not seen the [ CancellationException] stack trace printed on the console before. That is because
536
- inside a cancelled coroutine ` CancellationException ` is a considered a normal reason for coroutine completion.
536
+ inside a cancelled coroutine ` CancellationException ` is considered to be a normal reason for coroutine completion.
537
537
However, in this example we have used ` withTimeout ` right inside the ` main ` function.
538
538
539
539
Because cancellation is just an exception, all the resources will be closed in a usual way.
@@ -806,7 +806,7 @@ Produces the output:
806
806
807
807
<!-- - TEST LINES_START -->
808
808
809
- So, the coroutine the had inherited ` context ` of ` runBlocking {...} ` continues to execute in the ` main ` thread,
809
+ So, the coroutine that had inherited ` context ` of ` runBlocking {...} ` continues to execute in the ` main ` thread,
810
810
while the unconfined one had resumed in the scheduler thread that [ delay] function is using.
811
811
812
812
### Debugging coroutines and threads
@@ -1905,7 +1905,7 @@ fun main(args: Array<String>) = runBlocking<Unit> {
1905
1905
}
1906
1906
}
1907
1907
println (result)
1908
- val countActive = list.sumBy { deferred -> if (deferred .isActive) 1 else 0 }
1908
+ val countActive = list.count { it .isActive }
1909
1909
println (" $countActive coroutines are still active" )
1910
1910
}
1911
1911
```
Original file line number Diff line number Diff line change @@ -42,6 +42,6 @@ fun main(args: Array<String>) = runBlocking<Unit> {
42
42
}
43
43
}
44
44
println (result)
45
- val countActive = list.sumBy { deferred -> if (deferred .isActive) 1 else 0 }
45
+ val countActive = list.count { it .isActive }
46
46
println (" $countActive coroutines are still active" )
47
47
}
You can’t perform that action at this time.
0 commit comments