> For the complete documentation index, see [llms.txt](https://ryanyang.gitbook.io/the-way-to-go-zh-cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ryanyang.gitbook.io/the-way-to-go-zh-cn/di-si-bu-fen-shi-ji-ying-yong/16.0/16.8.md).

# 误用协程和通道

由于教学需要和对协程的工作原理有一个直观的了解，在[第14章](/the-way-to-go-zh-cn/di-san-bu-fen-go-gao-ji-bian-cheng/14.0.md)使用了一些简单的算法，举例说明了协程和通道的使用，例如生产者或者迭代器。在实际应用中，你不需要并发执行，或者你不需要关注协程和通道的开销，在大多数情况下，通过栈传递参数会更有效率。

但是，如果你使用`break`、`return`或者`panic`去跳出一个循环，很有可能会导致内存溢出，因为协程正处理某些事情而被阻塞。在实际代码中，通常仅需写一个简单的过程式循环即可。**当且仅当代码中并发执行非常重要，才使用协程和通道。**

## 链接

* [目录](https://github.com/yangchuansheng/the-way-to-go_ZH_CN/tree/f30ab7d8c58f85840a0afb548024b93642b518d5/eBook/directory.md)
* 上一节：[使用值类型时误用指针](/the-way-to-go-zh-cn/di-si-bu-fen-shi-ji-ying-yong/16.0/16.7.md)
* 下一节：[闭包和协程的使用](/the-way-to-go-zh-cn/di-si-bu-fen-shi-ji-ying-yong/16.0/16.9.md)
