go:goroutine

This commit is contained in:
Logen Kain 2017-09-27 04:08:09 -07:00
parent 1a4517a49f
commit c57f8e4a86

19
go/goroutine/main.go Normal file
View File

@ -0,0 +1,19 @@
package main
import (
"fmt"
"time"
)
func delay_string(str string) {
time.Sleep(100 * time.Millisecond)
fmt.Println(str)
}
func main() {
go delay_string("world!")
fmt.Println("hello")
// Added to avoid the program ending before the routine finished
time.Sleep(100 * time.Millisecond * 2)
}