File tree 1 file changed +8
-8
lines changed
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.
13
13
14
14
## Selecting from channels
15
15
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:
17
17
18
18
``` kotlin
19
19
fun 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 )
22
22
send(" Fizz" )
23
23
}
24
24
}
25
25
```
26
26
27
- And the ` buzz ` produces "Buzz!" string every 500 ms:
27
+ And the ` buzz ` produces "Buzz!" string every 1000 ms:
28
28
29
29
``` kotlin
30
30
fun 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 )
33
33
send(" Buzz!" )
34
34
}
35
35
}
@@ -62,14 +62,14 @@ import kotlinx.coroutines.channels.*
62
62
import kotlinx.coroutines.selects.*
63
63
64
64
fun CoroutineScope.fizz () = produce<String > {
65
- while (true ) { // sends "Fizz" every 300 ms
65
+ while (true ) { // sends "Fizz" every 500 ms
66
66
delay(500 )
67
67
send(" Fizz" )
68
68
}
69
69
}
70
70
71
71
fun CoroutineScope.buzz () = produce<String > {
72
- while (true ) { // sends "Buzz!" every 500 ms
72
+ while (true ) { // sends "Buzz!" every 1000 ms
73
73
delay(1000 )
74
74
send(" Buzz!" )
75
75
}
You can’t perform that action at this time.
0 commit comments