package main
import (
"fmt"
"time"
)
func goroutine(ch chan<- string) {
time.Sleep(time.Second * 1)
ch <- "done"
}
func main() {
buffer := 3
ch := make(chan string, buffer)
go goroutine(ch)
go goroutine(ch)
go goroutine(ch)
// wait for all goroutines to finish
for len(ch) < buffer {
}
close(ch)
fmt.Println("Done")
}
To embed this project on your website, copy the following code and paste it into your website's HTML: