Created
January 9, 2020 07:13
-
-
Save edwinlab/7068c25c6931241f694237a3e78a2c41 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 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