- 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.
推薦閱讀
- 深入理解Django:框架內(nèi)幕與實現(xiàn)原理
- Android 9 Development Cookbook(Third Edition)
- 軟件測試項目實戰(zhàn)之性能測試篇
- 深入淺出Android Jetpack
- MariaDB High Performance
- 算法訓練營:提高篇(全彩版)
- Haskell Data Analysis Cookbook
- 一塊面包板玩轉(zhuǎn)Arduino編程
- Vue.js應用測試
- QGIS 2 Cookbook
- Java Web開發(fā)實例大全(基礎卷) (軟件工程師開發(fā)大系)
- HTML+CSS+JavaScript網(wǎng)頁制作:從入門到精通(第4版)
- Robot Framework Test Automation
- Ionic3與CodePush初探:支持跨平臺與熱更新的App開發(fā)技術(shù)
- Raspberry Pi開發(fā)實戰(zhàn)