package main

import (
    "fmt"
    "time"
)

func say(s string) {
    for i := 0; i < 5; i++ {
        time.Sleep(100 * time.Millisecond)
        fmt.Println(s)
    }
}

func main() {
    go say("hello1")
    say("hello2")
}

输出:

hello2
hello1
hello1
hello2
hello2
hello1
hello2
hello1
hello2

 

相关文章:

  • 2022-12-23
  • 2021-12-24
  • 2021-11-20
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-13
  • 2022-02-11
  • 2022-02-08
  • 2022-03-02
相关资源
相似解决方案