Source file tour/concurrency/goroutines.go

     1  // +build OMIT
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  	"time"
     8  )
     9  
    10  func say(s string) {
    11  	for i := 0; i < 5; i++ {
    12  		time.Sleep(100 * time.Millisecond)
    13  		fmt.Println(s)
    14  	}
    15  }
    16  
    17  func main() {
    18  	go say("world")
    19  	say("hello")
    20  }
    21  

View as plain text