- 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.
推薦閱讀
- Modular Programming with Python
- Practical Data Science Cookbook(Second Edition)
- Apache Spark Graph Processing
- Python Data Analysis(Second Edition)
- Oracle Database 12c Security Cookbook
- PhpStorm Cookbook
- Reactive Android Programming
- 學習正則表達式
- R語言:邁向大數據之路(加強版)
- 從零開始學Android開發
- Kotlin語言實例精解
- Java 9:Building Robust Modular Applications
- 基于JavaScript的WebGIS開發
- Slick2D Game Development
- Visual C++ 開發從入門到精通