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

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.
主站蜘蛛池模板: 屯留县| 常宁市| 来安县| 阳曲县| 衡山县| 宜宾县| 无棣县| 桃江县| 龙门县| 宜黄县| 鄂尔多斯市| 池州市| 通辽市| 巧家县| 孝感市| 平乐县| 石台县| 蓬溪县| 定远县| 北碚区| 梨树县| 铁力市| 五家渠市| 克山县| 米易县| 盐城市| 清原| 洛浦县| 永新县| 收藏| 调兵山市| 齐齐哈尔市| 密云县| 韶关市| 天台县| 钦州市| 尚义县| 法库县| 铁岭市| 东台市| 大田县|