Skip to content

Instantly share code, notes, and snippets.

@phewdry
Created November 13, 2019 00:47
Show Gist options
  • Save phewdry/360832e8de78cf60db371585cfa83ac4 to your computer and use it in GitHub Desktop.
Save phewdry/360832e8de78cf60db371585cfa83ac4 to your computer and use it in GitHub Desktop.
var Wait sync.WaitGroup
var Counter int = 0
func main() {
for routine := 1; routine <= 2; routine++ {
Wait.Add(1)
go Routine(routine)
}
Wait.Wait()
fmt.Printf("Final Counter: %d\n", Counter)
}
func Routine(id int) {
for count := 0; count < 2; count++ {
value := Counter
value++
Counter = value
}
Wait.Done()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment