Skip to content

Instantly share code, notes, and snippets.

@jney
Created June 13, 2013 08:21
Show Gist options
  • Save jney/5772081 to your computer and use it in GitHub Desktop.
Save jney/5772081 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sync"
"time"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
go say("3 seconds", 3*time.Second, &wg)
wg.Add(1)
go say("2 seconds", 2*time.Second, &wg)
wg.Add(1)
go say("1 seconds", 1*time.Second, &wg)
wg.Wait()
}
func say(text string, duration time.Duration, wg *sync.WaitGroup) {
time.Sleep(duration)
fmt.Println(text)
wg.Done()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment