From f739040e1b649e9222582bf7e92abce91e8f1c75 Mon Sep 17 00:00:00 2001 From: Pearcekieser <5055971+Pearcekieser@users.noreply.github.com> Date: Wed, 23 Feb 2022 19:12:31 -0500 Subject: [PATCH] docs: improve Children of a coroutine example I think flipping the order of the print and delay makes it more clear that one coroutine is canceled while the other lives on. Also I added a note that explains why the delay is necessary. The need for the second delay wasn't immediately clear to me on first read of the coroutine guide. --- docs/topics/coroutine-context-and-dispatchers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/topics/coroutine-context-and-dispatchers.md b/docs/topics/coroutine-context-and-dispatchers.md index c5a869dff8..aaa461e1f7 100644 --- a/docs/topics/coroutine-context-and-dispatchers.md +++ b/docs/topics/coroutine-context-and-dispatchers.md @@ -334,8 +334,8 @@ fun main() = runBlocking { } delay(500) request.cancel() // cancel processing of the request - delay(1000) // delay a second to see what happens println("main: Who has survived request cancellation?") + delay(1000) // delay a second to keep main alive and see what happens //sampleEnd } ``` @@ -350,8 +350,8 @@ The output of this code is: ```text job1: I run in my own Job and execute independently! job2: I am a child of the request coroutine -job1: I am not affected by cancellation of the request main: Who has survived request cancellation? +job1: I am not affected by cancellation of the request ```