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

Flexible

Kotlin offers many different primitives that allow for simple-yet-flexible concurrency. You will find that there are many ways to do concurrent programming in Kotlin. Here is a list of some of the topics we will look at throughout the book:

  • Channels: Pipes that can be used to safely send and receive data between coroutines.
  • Worker pools: A pool of coroutines that can be used to divide the processing of a set of operations in many threads.
  • Actors: A wrapper around a state that uses channels and coroutines as a mechanism to offer the safe modification of a state from many different threads.
  • Mutual exclusions (Mutexes): A synchronization mechanism that allows the definition of a critical zone so that only one thread can execute at a time. Any coroutine trying to access the critical zone will be suspended until the previous coroutine leaves.
  • Thread confinement: The ability to limit the execution of a coroutine so that it always happens in a specified thread.
  • Generators (Iterators and sequences): Data sources that can produce information on demand and be suspended when no new information is required.

All of these are tools that are at your fingertips when writing concurrent code in Kotlin, and their scope and use will help you to make the right choices when implementing concurrent code.

主站蜘蛛池模板: 仙桃市| 成都市| 诸暨市| 翼城县| 东丰县| 汾西县| 惠东县| 新昌县| 定日县| 英山县| 通河县| 吉首市| 寿光市| 杭州市| 六盘水市| 吉安市| 连山| 增城市| 临泽县| 蒙山县| 五大连池市| 通州区| 金沙县| 永吉县| 五河县| 宁蒗| 灵武市| 锡林浩特市| 卢湾区| 高密市| 镇康县| 永仁县| 饶河县| 盐山县| 石林| 河西区| 兴安盟| 凌源市| 含山县| 塔城市| 五家渠市|