package main
import (
"fmt"
"time"
)
func thisTakesForever(id int, ch chan<- string) {
time.Sleep(time.Second * 2)
ch <- "done"
}
func main() {
start := time.Now()
buffer := 3
ch := make(chan string, buffer)
go thisTakesForever(111, ch)
go thisTakesForever(222, ch)
go thisTakesForever(333, ch)
for len(ch) < buffer {
}
close(ch)
fmt.Println("Done in", time.Since(start))
}
To embed this project on your website, copy the following code and paste it into your website's HTML: