- 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.
推薦閱讀
- 自制編譯器
- 數(shù)據(jù)結(jié)構(gòu)習(xí)題精解(C語(yǔ)言實(shí)現(xiàn)+微課視頻)
- JavaScript前端開(kāi)發(fā)與實(shí)例教程(微課視頻版)
- Python高效開(kāi)發(fā)實(shí)戰(zhàn):Django、Tornado、Flask、Twisted(第2版)
- YARN Essentials
- Learning Python Design Patterns
- Cocos2d-x學(xué)習(xí)筆記:完全掌握Lua API與游戲項(xiàng)目開(kāi)發(fā) (未來(lái)書(shū)庫(kù))
- 區(qū)塊鏈底層設(shè)計(jì)Java實(shí)戰(zhàn)
- Lighttpd源碼分析
- Spring MVC+MyBatis開(kāi)發(fā)從入門(mén)到項(xiàng)目實(shí)踐(超值版)
- Laravel Application Development Blueprints
- Unity Android Game Development by Example Beginner's Guide
- SAP Web Dynpro for ABAP開(kāi)發(fā)技術(shù)詳解:基礎(chǔ)應(yīng)用
- Mastering Object:Oriented Python(Second Edition)
- 多接入邊緣計(jì)算實(shí)戰(zhàn)