// Homework 36, problem 3: Breakfast. // // Three jobs run one after another, and the program prints how long that // took (about 1.2s). Make the three jobs run at the same time, and wait for // them, so that the whole breakfast takes about as long as the slowest job. // // Run with: go run exercises/36/homework/03-breakfast.go package main import ( "fmt" "time" ) // cook pretends to do a kitchen job that takes the given time. func cook(job string, d time.Duration) { time.Sleep(d) fmt.Println("Finished:", job) } func main() { start := time.Now() // TODO: run these three at the same time. cook("boil the water", 500*time.Millisecond) cook("fry the egg", 400*time.Millisecond) cook("toast the bread", 300*time.Millisecond) fmt.Println("Breakfast took", time.Since(start).Round(100*time.Millisecond)) }