Last active
July 4, 2018 06:05
-
-
Save ksakae1216/80435d5c69ddf70b8d092edaabfdb1fe to your computer and use it in GitHub Desktop.
This file contains 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 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