mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-08-03 13:12:16 +02:00
initial import
This commit is contained in:
33
microservices/go-channel/main.go
Normal file
33
microservices/go-channel/main.go
Normal file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
tc := make(chan time.Time)
|
||||
|
||||
var c int64 = 0
|
||||
|
||||
go func() {
|
||||
for {
|
||||
go func() {
|
||||
for {
|
||||
c++
|
||||
i := rand.Int31n(10)
|
||||
time.Sleep(time.Duration(i) * time.Millisecond)
|
||||
tc <- time.Now()
|
||||
}
|
||||
}()
|
||||
}
|
||||
}()
|
||||
|
||||
for t := range tc {
|
||||
fmt.Println(t)
|
||||
fmt.Println(c)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user