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

Putting things together

So far, we have learned that an application is composed of one or more processes and that each process has one or more threads. We have also learned that blocking a thread means halting the execution of the code in that thread, and for that reason, a thread that interacts with a user is expected to never be blocked. We also know that a coroutine is basically a lightweight thread that resides in a thread but is not tied to one. The following diagram encapsulates the content of this section so far. Notice how each coroutine is started in one thread but at some point is resumed in a different one:

In a nutshell, concurrency occurs when an application runs in more than one thread at the same time. So in order for concurrency to happen, two or more threads need to be created, and both communication and synchronization of those threads will most likely be needed for correct functioning of the application.

Later in this chapter, the differences between concurrency and parallelism will be discussed.
主站蜘蛛池模板: 台南市| 土默特右旗| 靖江市| 天水市| 新乡市| 静海县| 济阳县| 南投市| 鸡西市| 宜都市| 巫山县| 山西省| 宝应县| 镇安县| 达拉特旗| 新民市| 伊金霍洛旗| 双峰县| 澄城县| 达尔| 吉木萨尔县| 义马市| 鄢陵县| 舒城县| 景谷| 温宿县| 健康| 炉霍县| 南充市| 宁南县| 榆中县| 益阳市| 平潭县| 高雄县| 绥化市| 运城市| 民勤县| 廉江市| 中阳县| 宁远县| 南木林县|