<lambda>null1// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. 2 package kotlinx.coroutines.guide.exampleCancel05 3 4 import kotlinx.coroutines.* 5 6 fun main() = runBlocking { 7 val job = launch { 8 try { 9 repeat(1000) { i -> 10 println("job: I'm sleeping $i ...") 11 delay(500L) 12 } 13 } finally { 14 println("job: I'm running finally") 15 } 16 } 17 delay(1300L) // delay a bit 18 println("main: I'm tired of waiting!") 19 job.cancelAndJoin() // cancels the job and waits for its completion 20 println("main: Now I can quit.") 21 } 22