Created
November 13, 2019 00:47
-
-
Save phewdry/360832e8de78cf60db371585cfa83ac4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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