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

Summary

This chapter was a detailed introduction to many important concepts and tools involved in concurrency, and acts as a foundation for the upcoming chapters. So here's a summary to help you remember some of the most important points that we discussed:

  • An application has one or more processes; each of them has at least one thread, and coroutines are executed inside a thread.
  • A coroutine can be executed in a different thread each time it's resumed, but can also be confined to a specific thread.
  • An application is concurrent when its execution happens in more than one overlapping thread.
  • To write correct concurrent code, it's necessary to learn how to communicate and synchronize the different threads, which in Kotlin implies the communication and synchronization of coroutines.
  • Parallelism happens when, during the execution of a concurrent application, at least two threads are effectively being executed simultaneously.
  • Concurrency can happen without parallelism because modern processing units will interleave between threads, effectively overlapping threads.
  • There are many challenges when it comes to writing concurrent code, most of them related to correct communication and the synchronization of threads. Race conditions, atomicity violations, deadlocks, and livelocks are examples of the most common challenges.
  • Kotlin has taken a modern and fresh approach to concurrency. With Kotlin, it's possible and encouraged to write non-blocking, readable, leveraged, and flexible concurrent code.

In the next chapter, we will work with coroutines. We will start by configuring Android Studio and creating a project that supports coroutines. Then we will write and run concurrent code in an Android emulator, using coroutines for real-world scenarios such as REST calls. We will look at practical examples of suspending functions.

主站蜘蛛池模板: 新化县| 陆河县| 安达市| 嘉鱼县| 邛崃市| 裕民县| 博湖县| 剑河县| 镇江市| 酉阳| 崇义县| 宁晋县| 麻栗坡县| 桂阳县| 门源| 当雄县| 昌宁县| 呼伦贝尔市| 张家口市| 元氏县| 南丹县| 肇源县| 西平县| 那曲县| 绥阳县| 阆中市| 甘德县| 连山| 错那县| 昭觉县| 昭平县| 黑龙江省| 枞阳县| 南丰县| 新竹县| 黄龙县| 湘潭县| 无棣县| 华亭县| 县级市| 龙川县|