golang 无缓冲channel
package main
import "fmt"
func main() {
// 1S =1000ms
//1ms = 1000us
//1us =1000ns
/*
定义channel:make(chan 类型,容量)
ch :=make(chan string)
写端 ch <-"hello"
读端 str := <-ch
*/
ch :=make(chan string) //无缓冲channel
fmt.Println("len(ch)=",len(ch),"cap(ch)=",cap(ch))
go func() {
for i:=0;i<2;i++{
fmt.Println("i=",i)
}
ch <-"子go打印完毕"
}()
str := <-ch
fmt.Println("str=",str)
}