File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
kotlinx-coroutines-core/jvm/test/guide Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -13,23 +13,23 @@ the first one that becomes available.
1313
1414## Selecting from channels
1515
16- Let us have two producers of strings: ` fizz ` and ` buzz ` . The ` fizz ` produces "Fizz" string every 300 ms:
16+ Let us have two producers of strings: ` fizz ` and ` buzz ` . The ` fizz ` produces "Fizz" string every 500 ms:
1717
1818``` kotlin
1919fun CoroutineScope.fizz () = produce<String > {
20- while (true ) { // sends "Fizz" every 300 ms
21- delay(300 )
20+ while (true ) { // sends "Fizz" every 500 ms
21+ delay(500 )
2222 send(" Fizz" )
2323 }
2424}
2525```
2626
27- And the ` buzz ` produces "Buzz!" string every 500 ms:
27+ And the ` buzz ` produces "Buzz!" string every 1000 ms:
2828
2929``` kotlin
3030fun CoroutineScope.buzz () = produce<String > {
31- while (true ) { // sends "Buzz!" every 500 ms
32- delay(500 )
31+ while (true ) { // sends "Buzz!" every 1000 ms
32+ delay(1000 )
3333 send(" Buzz!" )
3434 }
3535}
@@ -62,14 +62,14 @@ import kotlinx.coroutines.channels.*
6262import kotlinx.coroutines.selects.*
6363
6464fun CoroutineScope.fizz () = produce<String > {
65- while (true ) { // sends "Fizz" every 300 ms
65+ while (true ) { // sends "Fizz" every 500 ms
6666 delay(500 )
6767 send(" Fizz" )
6868 }
6969}
7070
7171fun CoroutineScope.buzz () = produce<String > {
72- while (true ) { // sends "Buzz!" every 500 ms
72+ while (true ) { // sends "Buzz!" every 1000 ms
7373 delay(1000 )
7474 send(" Buzz!" )
7575 }
Original file line number Diff line number Diff line change @@ -10,14 +10,14 @@ import kotlinx.coroutines.channels.*
1010import kotlinx.coroutines.selects.*
1111
1212fun CoroutineScope.fizz () = produce<String > {
13- while (true ) { // sends "Fizz" every 300 ms
13+ while (true ) { // sends "Fizz" every 500 ms
1414 delay(500 )
1515 send(" Fizz" )
1616 }
1717}
1818
1919fun CoroutineScope.buzz () = produce<String > {
20- while (true ) { // sends "Buzz!" every 500 ms
20+ while (true ) { // sends "Buzz!" every 1000 ms
2121 delay(1000 )
2222 send(" Buzz!" )
2323 }
You can’t perform that action at this time.
0 commit comments