updatges
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import ("time"; "fmt")
|
||||
|
||||
func main() {
|
||||
ticker := time.NewTicker(time.Millisecond * 500)
|
||||
go func() {
|
||||
for t := range ticker.C {
|
||||
fmt.Println("Tick at", t)
|
||||
}
|
||||
}()
|
||||
time.Sleep(time.Millisecond * 1500)
|
||||
ticker.Stop()
|
||||
fmt.Println("Ticker stopped")
|
||||
}
|
||||
18
090-tickers/tickers.go
Normal file
18
090-tickers/tickers.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// ## Tickers
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
ticker := time.NewTicker(time.Millisecond * 500)
|
||||
go func() {
|
||||
for t := range ticker.C {
|
||||
fmt.Println("Tick at", t)
|
||||
}
|
||||
}()
|
||||
time.Sleep(time.Millisecond * 1500)
|
||||
ticker.Stop()
|
||||
fmt.Println("Ticker stopped")
|
||||
}
|
||||
5
090-tickers/tickers.sh
Normal file
5
090-tickers/tickers.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
$ go run tickers.go
|
||||
Tick at 2012-09-23 11:29:56.487625 -0700 PDT
|
||||
Tick at 2012-09-23 11:29:56.988063 -0700 PDT
|
||||
Tick at 2012-09-23 11:29:57.488076 -0700 PDT
|
||||
Ticker stopped
|
||||
Reference in New Issue
Block a user