mirror of
https://github.com/SourceFellows/gobuch.git
synced 2024-10-22 13:57:13 +00:00
34 lines
356 B
Go
34 lines
356 B
Go
|
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)
|
||
|
}
|
||
|
|
||
|
}
|