File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
kotlinx-coroutines-core/src/test/kotlin/guide Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -1351,10 +1351,9 @@ received number:
13511351
13521352``` kotlin
13531353fun launchProcessor (id : Int , channel : ReceiveChannel <Int >) = launch(CommonPool ) {
1354- while (true ) {
1355- val x = channel.receive()
1354+ for (x in channel) {
13561355 println (" Processor #$id received $x " )
1357- }
1356+ }
13581357}
13591358```
13601359
Original file line number Diff line number Diff line change @@ -29,10 +29,9 @@ fun produceNumbers() = produce<Int>(CommonPool) {
2929}
3030
3131fun launchProcessor (id : Int , channel : ReceiveChannel <Int >) = launch(CommonPool ) {
32- while (true ) {
33- val x = channel.receive()
32+ for (x in channel) {
3433 println (" Processor #$id received $x " )
35- }
34+ }
3635}
3736
3837fun main (args : Array <String >) = runBlocking<Unit > {
You can’t perform that action at this time.
0 commit comments