- 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.
推薦閱讀
- 觸·心:DT時代的大數據精準營銷
- 軟件項目管理(第2版)
- Maven Build Customization
- Power Up Your PowToon Studio Project
- Scratch 3游戲與人工智能編程完全自學教程
- QGIS:Becoming a GIS Power User
- Swift語言實戰晉級
- Oracle 12c從入門到精通(視頻教學超值版)
- C#面向對象程序設計(第2版)
- 深入理解Kafka:核心設計與實踐原理
- PHP 7 Programming Blueprints
- C#程序設計基礎與實踐
- 面向物聯網的Android應用開發與實踐
- Python深度學習入門:從零構建CNN和RNN
- 三步學Python