Closing Channels
来源:互联网 发布:ios6不越狱安装软件 编辑:程序博客网 时间:2024/05/16 17:55
packagemain
import "fmt"
func main() {
jobs := make(chan int, 5)
done := make(chan bool)
go func() {
for {
j, more := <-jobs
if more {
fmt.Println("received job", j)
} else {
fmt.Println("received all jobs")
done <- true
return
}
}
}()
for j := 1; j <= 3; j++ {
jobs <- j
fmt.Println("sent job", j)
}
// 关闭通道
close(jobs)
fmt.Println("sent all jobs")
<-done
}
0 0
- Closing Channels
- closing
- 通道 Channels
- Configuring Channels
- Opening and Closing Windows
- linux Closing a Socket
- TCP closing a connection
- python contextlib.closing()
- CloseableReference: Finalized without closing
- usaco2016open silver3 closing
- usaco2016open gold2 closing
- tcp状态 closing
- python channels笔记--Getting started with channels
- Profit and Loss Closing Tcodesfrom
- codechef Closing the Tweets 题解
- codeforces 720 A. Closing ceremony
- BZOJ 4579 Closing the Farm
- uPortal channels资源
- 双向一对多外联关系(外键)
- Android FragmentActivity 和Activity的关系
- dlib交叉编译到arm
- iOS中 流媒体播放和下载 韩俊强的博客
- 属性动画详解
- Closing Channels
- GitHub如何使用
- 视频编码基础
- Convenience initialzer missing a self call to another initializer警告
- JS对于Android和IOS平台的点击响应的适配
- Android Studio 打包apk,自动追加版本号和版本名称
- C#使用SharpZipLib解压Zip单个文件到内存
- UIWebView与JavaScript(JS) 回调交互(oc与js交互)
- 基础三