Skip to content

Commit

Permalink
Update* channel notes
Browse files Browse the repository at this point in the history
  • Loading branch information
colynn authored Jan 17, 2024
1 parent 5f4360b commit e060173
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions content/posts/2019-12-31-go_basic_knowledge_summarizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ __注__:
## Goroutines和Channels
1. 如果我们使用了无缓存的channel, 那么两个慢的goroutines将会因为没有人接收而永远卡住。这种情况,称为goroutines泄漏,这将是一个BUG.和垃圾变量不同,泄漏的goroutines并不会被自动回收,因此确保每个不再需要的goroutine能正常退出是重要的。
2. 当 for range 遍历 channel 时,如果发送者没有关闭 channel 或在 range 之后关闭,都会导致 deadlock(死锁)。
3. 同步的 channel 千万不要在同一个 goroutine 协程里发送和接收数据。可能导致deadlock死锁。
## Labels in Go
Expand Down

0 comments on commit e060173

Please sign in to comment.