File tree 2 files changed +6
-0
lines changed 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -573,6 +573,7 @@ Now let's see how it works in practice:
573
573
import kotlinx.coroutines.*
574
574
import kotlinx.coroutines.channels.*
575
575
576
+ // sampleStart
576
577
fun main () = runBlocking<Unit > {
577
578
val tickerChannel = ticker(delayMillis = 100 , initialDelayMillis = 0 ) // create ticker channel
578
579
var nextElement = withTimeoutOrNull(1 ) { tickerChannel.receive() }
@@ -596,7 +597,9 @@ fun main() = runBlocking<Unit> {
596
597
597
598
tickerChannel.cancel() // indicate that no more elements are needed
598
599
}
600
+ // sampleEnd
599
601
```
602
+ {kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
600
603
601
604
> You can get the full code [ here] ( ../../kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt ) .
602
605
>
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ It can be demonstrated by a simple example that creates root coroutines using th
28
28
``` kotlin
29
29
import kotlinx.coroutines.*
30
30
31
+ // sampleStart
31
32
@OptIn(DelicateCoroutinesApi ::class )
32
33
fun main () = runBlocking {
33
34
val job = GlobalScope .launch { // root coroutine with launch
@@ -47,7 +48,9 @@ fun main() = runBlocking {
47
48
println (" Caught ArithmeticException" )
48
49
}
49
50
}
51
+ // sampleEnd
50
52
```
53
+ {kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
51
54
52
55
> You can get the full code [ here] ( ../../kotlinx-coroutines-core/jvm/test/guide/example-exceptions-01.kt ) .
53
56
>
You can’t perform that action at this time.
0 commit comments