Last active
November 26, 2015 01:48
-
-
Save samuell/03e1f4b9a20dbbef5f3c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"os/exec" | |
"sync" | |
) | |
func main() { | |
wg := new(sync.WaitGroup) | |
for i := 0; i < 355; i++ { | |
wg.Add(1) | |
go func(i int) { | |
fmt.Println("Starting sleep ", i, "...") | |
cmd := exec.Command("sleep", "3600") | |
_, err := cmd.Output() | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println("Finishing sleep ", i, "...") | |
wg.Done() | |
}(i) | |
} | |
fmt.Println("Waiting for WaitGroup ...") | |
wg.Wait() | |
fmt.Println("WaitGroup finished!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Testing it:
... so only like 691 threads, for those 1000 go routines ...