去评论
dz插件网

select

镖师
2023/07/27 11:07:04
  1. package main
  2. import (
  3.     "fmt"
  4.     "time"
  5. )
  6. func main() {
  7.     select {
  8.     case <-time.Tick(2 * time.Second):
  9.         fmt.Println("2 second over:", time.Now().Second())
  10.     case <-time.After(7 * time.Second):
  11.         fmt.Println("5 second over, timeover", time.Now().Second())
  12.         return
  13.     }
  14. }
请写出答案