package main
import(
"fmt"
)
func main() {
channelInt := make(chan int)
for i:= 0; i < 5; i++ {
j := i
go func(j int) {
channelInt <- j
}(j)
}
fmt.Printf("==>%d\n", <-channelInt)
}
更多评论
```
package main
import (
"fmt"
"time"
)
func main() {
channelInt := make(chan int)
for i := 0; i < 5; i++ {
j := i
go func(x int) {
channelInt <- x
}(j)
time.Sleep(1000)
}
fmt.Printf("==>%d\n", <-channelInt)
}
```
#3