package main import ( "fmt" "time" ) func printHello(c chan string) { c<- "\"Hello " time.Sleep(1* time.Second) } func printWorld(c chan string) { time.Sleep(1* time.Second) c<- "World\" " } func main() { start := time.Now() fmt.Print("This is my first concurrent ") c1:=make(chan string) c2:=make(chan string) go printHello(c1) go printWorld(c2) fmt.Println(<- c1,<- c2,"program") t := time.Now() elapsed := t.Sub(start) fmt.Println(elapsed) }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more