官术网_书友最值得收藏!

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.
主站蜘蛛池模板: 邛崃市| 扎兰屯市| 南通市| 石门县| 三台县| 武夷山市| 鹿泉市| 霞浦县| 玉树县| 嫩江县| 天全县| 黎城县| 凤凰县| 井陉县| 阜宁县| 崇州市| 卓尼县| 呼伦贝尔市| 镇巴县| 淮北市| 德庆县| 镇原县| 海门市| 安丘市| 潜山县| 珲春市| 应城市| 蕲春县| 如东县| 阳高县| 平潭县| 湖北省| 梧州市| 湟中县| 定日县| 陆良县| 新邵县| 大石桥市| 美姑县| 兰考县| 慈溪市|