2018-07-17
作者:
入秋未凉的海 | 来源:发表于
2018-07-18 21:50 被阅读0次

image.png

image.png

image.png
package main
import "fmt"
func main() {
message := make( chan string)
go func() {
message <- "hello goroutine!"
}()
str := <-message
fmt.Println(str)
fmt.Println("hello")
}
package main
import (
"fmt"
"time"
)
func main() {
message := make( chan string)
go func() {
message <- "hello goroutine!"
}()
go func() {
time.Sleep(2*time.Second)
str := <-message
str = str + "I'm goroutine!"
message <- str
}()
time.Sleep(3*time.Second)
str := <-message
fmt.Println(str)
fmt.Println("hello")
}

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png
本文标题:2018-07-17
本文链接:https://www.haomeiwen.com/subject/qljnpftx.html
网友评论