Skip to content

Instantly share code, notes, and snippets.

@ksakae1216
Last active Jul 4, 2018
Embed
What would you like to do?
package funcpkg
import (
"fmt"
"time"
"sync"
)
// SyncFunc 同期処理のサンプルです
func SyncFunc() {
wg := new(sync.WaitGroup)
for i := 0; i < 10; i++ {
wg.Add(1)
go func(cnt int) {
fmt.Println("start", cnt)
time.Sleep(1 * time.Millisecond)
fmt.Println("end", cnt)
wg.Done()
}(i)
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment