26 lines
312 B
Go
26 lines
312 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
func compute(value int, wg *sync.WaitGroup) {
|
||
|
for i := 0; i < value; i++ {
|
||
|
fmt.Println(i)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
wg := sync.WaitGroup{}
|
||
|
|
||
|
fmt.Println("Starting")
|
||
|
|
||
|
for c := 0; c < 1000000; c++ {
|
||
|
wg.Add(1)
|
||
|
go compute(10, &wg)
|
||
|
}
|
||
|
wg.Done()
|
||
|
fmt.Println("Finished")
|
||
|
}
|