New

As mentioned earlier, a job is, by default, started automatically both when it's created using launch() and when it's created using Job(). In order to create a job without starting it, you have to use CoroutineStart.LAZY when creating it. Consider the given example:

fun main(args: Array<String>) = runBlocking {
launch(start = CoroutineStart.LAZY) {
TODO("Not implemented yet!")
}

delay(500)
}

When running this snippet of code, you will note that it didn't print any errors. Since the job is created but never started, the exception will not be thrown:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.18.141