gobuch/concurrency/first-go-routine/main.go

20 lines
258 B
Go
Raw Permalink Normal View History

2020-08-21 04:26:40 +00:00
package main
import (
"fmt"
"math/rand"
"time"
)
func printOut() {
for i := 0; i < 10; i++ {
fmt.Printf("Print %v\n", i)
time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond)
}
}
func main() {
go printOut()
time.Sleep(5 * time.Second)
}