forked from steger/pr3-ws202627
28 lines
336 B
Go
28 lines
336 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func print(ci <-chan int) {
|
|
//TODO: implement
|
|
for value := range ci {
|
|
time.Sleep(100 * time.Millisecond)
|
|
fmt.Println(value)
|
|
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
|
|
c := make(chan int)
|
|
done := make(chan bool)
|
|
go func() { print(c); done <- true; close(done) }()
|
|
c <- 1
|
|
c <- 2
|
|
c <- 3
|
|
close(c)
|
|
<-done
|
|
}
|