Write a Go program to launch multiple goroutines and synchronize them using a WaitGroup.
MediumProblem Statement
Write a Go program to launch multiple goroutines and synchronize them using a WaitGroup.
Sample Input
Three goroutines printing messages.
Sample Output
Goroutine 3 Goroutine 2 Goroutine 1 All goroutines finished.
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
package main
import ("fmt" "sync")
func printMessage(message string, wg *sync.WaitGroup) {
// Implement the goroutine functionality
}
func main() {
// Launch and synchronize goroutines using WaitGroup
}
Input
Three goroutines printing messages.
Expected Output
Goroutine 3 Goroutine 2 Goroutine 1 All goroutines finished.