go的timer

       看程序:

package main

import (
	"fmt"
    "time"
)

func main() {
	time.AfterFunc(3 * time.Second, func() {fmt.Println("come here 1")})

	timer := time.NewTimer(4 * time.Second)
	<-timer.C
	fmt.Println("come here 2")

	<-time.After(5 * time.Second)
	fmt.Printf("come here 3")

	for {}
}

        一目了然。

 

你可能感兴趣的:(S1:,Go)