nguye...@hotmail.co.uk
unread,Dec 21, 2017, 12:14:32 PM12/21/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
I cannot set a d for func Sleep().
Here is the code:
package main
import (
"fmt"
"time"
)
var c = make(chan int)
func main() {
go send(0, 3)
go send(1, 2)
go send(2, 1)
for i := 0; i < 3; i++ {
fmt.Printf("%v %v\n", <-c, time.Now())
}
}
func send(v int, d 3.Second) {
time.Sleep(d)
c <- v
}