获得徽章 0
#挑战每日一条沸点# 今天接着之前耽搁了好多天的Go语言圣经继续学习,今天学习了channel和goroutines的基本特性之一,when one goroutine attempts a send operation on a channel, it will block if the channel is full. It will remain blocked until another goroutine attemps to receive from the same channel,k at which point the second operation will unblock. 反之亦然。简单来说,就是在channel里是空的时候,想要从channel里获取数据的goroutine会停下等待; 在channel里是满的时候,想要往channel里输送数据的goroutine会停下。这种锁(Block)的机制保证了goroutine是同步的
展开
评论
点赞