- Learning Concurrency in Kotlin
- Miguel Angel Castiblanco Torres
- 90字
- 2021-08-05 10:46:52
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:

推薦閱讀
- Python 3.7網絡爬蟲快速入門
- Oracle Exadata性能優化
- Twilio Best Practices
- C語言程序設計實訓教程
- JavaScript+jQuery開發實戰
- Learning Informatica PowerCenter 10.x(Second Edition)
- Web全棧工程師的自我修養
- 老“碼”識途
- Python時間序列預測
- PhoneGap:Beginner's Guide(Third Edition)
- Angular開發入門與實戰
- Integrating Facebook iOS SDK with Your Application
- Scala Data Analysis Cookbook
- Scala編程實戰
- Appcelerator Titanium:Patterns and Best Practices