- Learning Concurrency in Kotlin
- Miguel Angel Castiblanco Torres
- 126字
- 2021-08-05 10:46:51
Job
A job is a fire-and-forget task. An operation that, once started, you will not be waiting on, unless, maybe, there's an exception. The most common way to create a job is to use the launch() coroutine builder, as shown:
fun main(args: Array<String>) = runBlocking {
val job = launch {
// Do background task here
}
}
However, you can also use the Job() factory function, like this:
fun main(args: Array<String>) = runBlocking {
val job = Job()
}
Job is an interface, and both launch() and Job() return the JobSupport implementation, which is the basis of many implementations of Job. Deferred—which we will see as we move ahead —is an interface that extends Job.
推薦閱讀
- Learning Microsoft Windows Server 2012 Dynamic Access Control
- Spring Cloud Alibaba核心技術與實戰案例
- Redis Applied Design Patterns
- 算法訓練營:入門篇(全彩版)
- Animate CC二維動畫設計與制作(微課版)
- INSTANT CakePHP Starter
- 區塊鏈:以太坊DApp開發實戰
- Mastering AndEngine Game Development
- PhpStorm Cookbook
- ArcGIS By Example
- C語言程序設計
- JavaScript應用開發實踐指南
- Python網絡爬蟲技術與應用
- Django Design Patterns and Best Practices
- Python應用開發技術