@@ -364,6 +364,7 @@ only downwards. This can easily be demonstrated using the following example:
364
364
import kotlinx.coroutines.*
365
365
366
366
fun main () = runBlocking {
367
+ // sampleStart
367
368
val supervisor = SupervisorJob ()
368
369
with (CoroutineScope (coroutineContext + supervisor)) {
369
370
// launch the first child -- its exception is ignored for this example (don't do this in practice!)
@@ -389,8 +390,10 @@ fun main() = runBlocking {
389
390
supervisor.cancel()
390
391
secondChild.join()
391
392
}
393
+ // sampleEnd
392
394
}
393
395
```
396
+ {kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
394
397
395
398
> You can get the full code [ here] ( ../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-01.kt ) .
396
399
>
@@ -418,6 +421,7 @@ import kotlin.coroutines.*
418
421
import kotlinx.coroutines.*
419
422
420
423
fun main () = runBlocking {
424
+ // sampleStart
421
425
try {
422
426
supervisorScope {
423
427
val child = launch {
@@ -436,8 +440,10 @@ fun main() = runBlocking {
436
440
} catch (e: AssertionError ) {
437
441
println (" Caught an assertion error" )
438
442
}
443
+ // sampleEnd
439
444
}
440
445
```
446
+ {kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
441
447
442
448
> You can get the full code [ here] ( ../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-02.kt ) .
443
449
>
@@ -468,6 +474,7 @@ import kotlin.coroutines.*
468
474
import kotlinx.coroutines.*
469
475
470
476
fun main () = runBlocking {
477
+ // sampleStart
471
478
val handler = CoroutineExceptionHandler { _, exception ->
472
479
println (" CoroutineExceptionHandler got $exception " )
473
480
}
@@ -479,8 +486,10 @@ fun main() = runBlocking {
479
486
println (" The scope is completing" )
480
487
}
481
488
println (" The scope is completed" )
489
+ // sampleEnd
482
490
}
483
491
```
492
+ {kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
484
493
485
494
> You can get the full code [ here] ( ../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-03.kt ) .
486
495
>
0 commit comments