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

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.
主站蜘蛛池模板: 高安市| 丰台区| 安吉县| 德江县| 保康县| 山阴县| 忻城县| 宝坻区| 福鼎市| 堆龙德庆县| 潍坊市| 九龙坡区| 本溪市| 镇雄县| 平凉市| 隆德县| 威远县| 九龙县| 且末县| 延长县| 浪卡子县| 丹凤县| 南岸区| 洛南县| 威远县| 富顺县| 卢氏县| 济宁市| 咸宁市| 巨野县| 青田县| 红安县| 维西| 苍溪县| 滨海县| 临西县| 大方县| 富锦市| 宝坻区| 彭山县| 罗城|