有没有人可以解释这段代码呢?????

xmge · · 781 次点击
For unbuffered channel, the sender will block on the channel until the receiver receives the data from the channel, whilst the receiver will also block on the channel until sender sends data into the channel.
#3
更多评论
xmge
欲戴王冠 必承其重
##### 代码并行执行时,执行顺序不定,以下代码输出无规律 ```go package main import ( "fmt" "time" ) func main() { go func() { fmt.Println(1) }() go func() { fmt.Println(2) }() go func() { fmt.Println(3) }() time.Sleep(time.Second * 1) } ```
#1
两种可能 如果先执行27行,则输出:a, 1, b, 2, c, 3, d, 4 如果先执行18行,则什么都不输出
#2