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

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.
主站蜘蛛池模板: 彭山县| 周口市| 莫力| 平昌县| 绥阳县| 高安市| 庆安县| 玛纳斯县| 通山县| 类乌齐县| 云南省| 通榆县| 兴业县| 繁昌县| 丘北县| 依安县| 夹江县| 永寿县| 乃东县| 扎赉特旗| 邵阳市| 延安市| 谢通门县| 碌曲县| 大埔区| 保亭| 任丘市| 龙江县| 深泽县| 拜城县| 海兴县| 南宫市| 旬邑县| 孝昌县| 兰考县| 寻乌县| 金华市| 托里县| 兰溪市| 万全县| 中西区|