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

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.
主站蜘蛛池模板: 台北县| 固原市| 额尔古纳市| 岳阳市| 淮南市| 富顺县| 莫力| 华容县| 宽城| 望都县| 会昌县| 大竹县| 临夏县| 比如县| 山东| 阿拉善盟| 准格尔旗| 九台市| 保康县| 宁乡县| 新津县| 保康县| 浮梁县| 宝清县| 栾城县| 贵德县| 嘉义县| 冀州市| 浠水县| 德惠市| 定日县| 莱芜市| 灯塔市| 吉木乃县| 延安市| 团风县| 新乐市| 高州市| 巨鹿县| 韶关市| 任丘市|