Skip to content

Instantly share code, notes, and snippets.

@ksakae1216
Last active July 4, 2018 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksakae1216/80435d5c69ddf70b8d092edaabfdb1fe to your computer and use it in GitHub Desktop.
Save ksakae1216/80435d5c69ddf70b8d092edaabfdb1fe to your computer and use it in GitHub Desktop.
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