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

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.
主站蜘蛛池模板: 西安市| 葵青区| 通州区| 武安市| 沙坪坝区| 花垣县| 乳山市| 台安县| 军事| 阿勒泰市| 色达县| 唐海县| 弥渡县| 内黄县| 女性| 谷城县| 龙游县| 永昌县| 玉林市| 永济市| 五莲县| 宁南县| 碌曲县| 东丽区| 武城县| 阳江市| 涡阳县| 柘城县| 香河县| 乐陵市| 亳州市| 灌云县| 中牟县| 福贡县| 新野县| 同江市| 怀宁县| 隆安县| 江陵县| 洪湖市| 张家口市|