goroutine与调度器
goroutine背后的系统知识
关于Goroutine与Channel
Golang Channel用法简编
1、通过goroutine、channel实现同步
package main import ( "fmt" "time" ) func f(r int) { c1 := make(chan bool, 1) //非缓冲通道 go func() { //do something fmt.Println("Do something") time.Sleep(time.Second) //end,send to channel c1 <- true }() if <-c1 { fmt.Println("Receive response") } }