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

Summary

Goroutines are concurrent and, to an extent, parallel; however, we should think of them as being concurrent. The order of execution of goroutines is not predictable and we should not rely on them to be executed in any particular order.

We should also take care to handle errors and panics in our goroutines because even though they are being executed in parallel, a panic in one goroutine will crash the complete program. Finally, goroutines can block on system calls, however this will not block the execution of the program nor slow down the performance of the overall program.

We looked at a few of the design concepts behind Go's runtime scheduler to understand why all of this happens.

You might be wondering why we haven't discussed channels in this chapter. The reason is that by not relying on channels we were able to look at goroutines in their most elemental form. This allowed us to dive deeper into the concept and implementation of goroutines.

In the next chapter, we shall be looking at channels and how they further empower goroutines.

主站蜘蛛池模板: 石城县| 孝感市| 台北市| 绥江县| 鱼台县| 永泰县| 延津县| 海淀区| 凉山| 涪陵区| 芒康县| 山东省| 宝山区| 沙雅县| 赣州市| 德兴市| 财经| 呼图壁县| 南丰县| 巴中市| 彩票| 阿城市| 都昌县| 阜阳市| 宽城| 彭州市| 普洱| 娱乐| 文安县| 逊克县| 改则县| 屏山县| 天峻县| 吴忠市| 白河县| 鹤山市| 琼海市| 新乡县| 镶黄旗| 阿坝县| 和平县|