fork download
  1. //concurrency
  2. package main
  3. import "fmt"
  4. import "time"
  5.  
  6. func ready(w string, sec int) {
  7. time.Sleep(int64(sec) * 1e9)
  8. fmt.Println(w, "is ready!")
  9. }
  10.  
  11. func main() {
  12. go ready("Tea", 2)
  13. go ready("Coffee", 1)
  14. fmt.Println("I'm Waiting")
  15. time.Sleep(5 * 1e9)
  16. }
  17.  
Success #stdin #stdout 0.02s 3120KB
stdin
Standard input is empty
stdout
I'm Waiting
Coffee is ready!
Tea is ready!