You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
golang-tutorial/demo/channel/goroutines.go

28 lines
389 B

package main
import (
"fmt"
)
func hello(done chan bool) {
fmt.Println("This is hello goroutines")
done <- true
}
func getName(name chan string) {
fmt.Println("This is getName goroutines")
name <- "Tinywan"
}
func main() {
done := make(chan bool)
go hello(done)
<-done
name := make(chan string)
go getName(name)
fmt.Println(<-name)
fmt.Println("This is main function")
}