Kotlin 并发编程之"协程"
Kotlin协程简介
Kotlin, as a language, provides only minimal low-level APIs in its standard library to enable various other libraries to utilize coroutines. Unlike many other languages with similar capabilities, async
and await
are not keywords in Kotlin and are not even part of its standard library. Moreover, Kotlin's concept of suspending function provides a safer and less error-prone abstraction for asynchronous operations than futures and promises.
kotlinx.coroutines
is a rich library for coroutines developed by JetBrains. It contains a number of high-level coroutine-enabled primitives that this guide covers, including launch
, async
and others.
This is a guide on core features of kotlinx.coroutines
with a series of examples, divided up into different topics.
In order to use coroutines as well as follow the examples in this guide, you ne
相关文章
- XTask与Kotlin Coroutine的使用对比
- Java 并发编程中的死锁 ( Kotlin 语言讲解)
- kotlin 之单例类详解
- kotlin能否取代java(kotlin的历史以及现状)
- Kotlin安卓编程—-生命周期以及启动方式
- 【Kotlin】Kotlin 自定义组件 ( 自定义 View | 自定义 SurfaceView )
- 【Jetpack】DataBinding 架构组件 ② ( 字符串拼接函数 | 绑定点击事件函数 | DataBinding 布局中使用 import 标签导入 Java、Kotlin 类 )
- 【Kotlin 协程】协程启动 ③ ( 协程组合并发 | 挂起函数串行执行 | 协程组合并发执行挂起函数 )
- 【Kotlin 协程】协程启动 ⑤ ( 协程作用域构建器 | runBlocking 函数 | coroutineScope 函数 | supervisorScope 函数 )
- 【Kotlin 协程】Channel 通道 ② ( Channel 通道容量 | Channel 通道迭代 | 使用 iterator 迭代器进行迭代 | 使用 for in 循环进行迭代 )
- 【Kotlin 协程】协程并发安全问题 ( 使用 Atomic 并发安全类型 | 使用 Channel 通道 | 使用 Mutext 轻量级锁 | 使用 Semaphore 轻量级信号量 )
- 【Kotlin】函数式编程 ③ ( 早集合与惰性集合 | 惰性集合-序列 | generateSequence 序列创建函数 | 序列代码示例 | take 扩展函数分析 )
- 【Kotlin】Kotlin 与 Java 互操作 ③ ( Kotlin 中处理 Java 异常 | Java 中处理 Kotlin 异常 | @Throws 注解处理异常 | 函数类型互相操作 )
- Android Studio配置Kotlin环境详解手机开发