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

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.

主站蜘蛛池模板: 扎赉特旗| 阿拉善左旗| 延吉市| 景宁| 盐山县| 南华县| 勐海县| 长丰县| 泊头市| 镇巴县| 简阳市| 乐平市| 鄱阳县| 奉贤区| 建阳市| 双流县| 晋宁县| 逊克县| 万盛区| 白山市| 乐业县| 巨鹿县| 永定县| 宜都市| 兰考县| 五莲县| 连州市| 平原县| 阜城县| 汉寿县| 扶风县| 遂川县| 商南县| 文安县| 大同县| 黄浦区| 保康县| 浦县| 绵竹市| 凌云县| 库车县|