- Learning Concurrency in Kotlin
- Miguel Angel Castiblanco Torres
- 167字
- 2021-08-05 10:46:44
Non-blocking
Threads are heavy, expensive to create, and limited—only so many threads can be created—So when a thread is blocked it is, in a way, being wasted. Because of this, Kotlin offers what is called Suspendable Computations; these are computations that can suspend their execution without blocking the thread of execution. So instead of, for example, blocking thread X to wait for an operation to be made in a thread Y, it's possible to suspend the code that has to wait and use thread X for other computations in the meantime.
Furthermore, Kotlin offers great primitives like channels, actors, and mutual exclusions, which provide mechanisms to communicate and synchronize concurrent code effectively without having to block a thread.
Chapter 6, Channels – Share Memory by Communicating, Chapters 7, Thread Confinement, Actors, and Mutexes, and Chapter 8, Testing Concurrent Code, will focus on the correct usage of channels, actors, mutexes, and more to correctly communicate and synchronize your concurrent code.
推薦閱讀
- 深度實踐OpenStack:基于Python的OpenStack組件開發
- JavaScript全程指南
- 潮流:UI設計必修課
- Learning RxJava
- SQL for Data Analytics
- INSTANT MinGW Starter
- Building a Recommendation Engine with Scala
- OpenShift在企業中的實踐:PaaS DevOps微服務(第2版)
- Android Native Development Kit Cookbook
- 微信小程序項目開發實戰
- VMware虛擬化技術
- Mastering openFrameworks:Creative Coding Demystified
- 軟件供應鏈安全:源代碼缺陷實例剖析
- 微前端設計與實現
- Drupal Search Engine Optimization