Skip to content

Instantly share code, notes, and snippets.

@edwinlab
Created January 9, 2020 07:13
Show Gist options
  • Save edwinlab/7068c25c6931241f694237a3e78a2c41 to your computer and use it in GitHub Desktop.
Save edwinlab/7068c25c6931241f694237a3e78a2c41 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sync"
)
func main() {
ConcurrentFunctions(func1, func2, func3, func4)
}
func ConcurrentFunctions(fns ...func()) {
var wg sync.WaitGroup
for _, fn := range fns {
wg.Add(1)
go func(f func()) {
f()
wg.Done()
}(fn)
}
wg.Wait()
}
func func1() {
fmt.Println("I am function func1")
}
func func2() {
fmt.Println("I am function func2")
}
func func3() {
fmt.Println("I am function func3")
}
func func4() {
fmt.Println("I am function func4")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment