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

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.

主站蜘蛛池模板: 长兴县| 万安县| 贵德县| 凤翔县| 兴仁县| 犍为县| 中山市| 万源市| 富裕县| 达拉特旗| 乌海市| 甘泉县| 沅江市| 平陆县| 贵溪市| 礼泉县| 海门市| 兴文县| 双江| 如皋市| 云浮市| 德钦县| 安泽县| 盐城市| 安庆市| 洛宁县| 昌都县| 彰化市| 乌审旗| 迁安市| 锡林郭勒盟| 弋阳县| 绥江县| 潼关县| 太仓市| 元氏县| 台北市| 黔东| 三原县| 丘北县| 深圳市|