### 实际输出: main done
### 期望输出:有bug !main done
```
package main
import (
"fmt"
"sync"
)
func main() {
ch2 := make(chan int, 1000)
var wg sync.WaitGroup
go testThreadSate01(ch2, &wg)
go testThreadSate02(ch2, &wg)
go testThreadSate03(ch2, &wg)
go func() {
for {
select {
case res := <-ch2:
if res == 28 {
break
}
case resGt := <-ch2:
if resGt > 28 {
fmt.Println("有bug !")
break
}
default:
}
}
}()
wg.Wait()
fmt.Println("main done")
}
func testThreadSate03(ch chan int, wg *sync.WaitGroup) {
defer wg.Done()
wg.Add(1)
for j := 21; j <= 30; j++ {
ch <- j
}
}
func testThreadSate01(ch chan int, wg *sync.WaitGroup) {
defer wg.Done()
wg.Add(1)
for j := 0; j <= 10; j++ {
ch <- j
}
}
func testThreadSate02(ch chan int, wg *sync.WaitGroup) {
defer wg.Done()
wg.Add(1)
//time.Sleep(1 * time.Microsecond)
for j := 11; j <= 20; j++ {
ch <- j
}
}
```
有疑问加站长微信联系(非本文作者)