Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/gorun
- package main
- import (
- "fmt"
- "runtime"
- "sync"
- )
- var summ uint64
- var wg sync.WaitGroup
- func summator() {
- defer wg.Done()
- for i := uint64(0); i < 100000; i++ {
- summ = summ + 1
- }
- }
- func main() {
- wg.Add(100000)
- for i := uint64(0); i < 100000; i++ {
- go summator()
- }
- wg.Wait()
- fmt.Printf("summ == %d\n", summ)
- }
- func init() {
- runtime.GOMAXPROCS(runtime.NumCPU())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement