Files
the-way-to-go_ZH_CN/eBook/exercises/chapter_14/channel_buffer.go
2015-03-03 12:25:25 -05:00

21 lines
347 B
Go
Executable File

package main
import "fmt"
import "time"
func main() {
c := make(chan int, 50)
go func() {
time.Sleep(15 * 1e9)
x := <-c
fmt.Println("received", x)
}()
fmt.Println("sending", 10)
c <- 10
fmt.Println("sent", 10)
}
/* Output:
sending 10
sent 10 // prints immediately
no further output, because main() then stops
*/