File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
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 }
You can’t perform that action at this time.
0 commit comments