Created
November 8, 2022 20:05
-
-
Save BetterProgramming/b1bd8ffb42e86a676ceee87d59bef69d 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
func main() { | |
runtime.GOMAXPROCS(2) | |
var wg sync.WaitGroup | |
wg.Add(2) | |
fmt.Printf("Starting") | |
go func() { | |
defer wg.Done() | |
for n := 0; n < 10; n++ { | |
fmt.Printf("%d\n", n) | |
} | |
}() | |
go func() { | |
defer wg.Done() | |
for n := 100; n < 200; n++ { | |
fmt.Printf("%d\n", n) | |
} | |
}() | |
fmt.Println("Waiting...") | |
wg.Wait() | |
fmt.Println("Finish!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment