mirror of
https://gitee.com/johng/gf
synced 2026-07-07 06:15:15 +08:00
32 lines
487 B
Go
32 lines
487 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
events1 := make(chan int, 100)
|
|
events2 := make(chan int, 100)
|
|
//go func() {
|
|
// for{
|
|
// v := <- events1
|
|
// fmt.Println(v)
|
|
// }
|
|
//
|
|
//}()
|
|
|
|
go func() {
|
|
time.Sleep(2*time.Second)
|
|
events1 <- 1
|
|
events2 <- 2
|
|
time.Sleep(2*time.Second)
|
|
close(events1)
|
|
close(events2)
|
|
events1 <- 1
|
|
events2 <- 2
|
|
}()
|
|
|
|
select {
|
|
|
|
}
|
|
} |