Skip to content

Instantly share code, notes, and snippets.

@yssk22
Created May 6, 2013 11:39
Show Gist options
  • Save yssk22/5524656 to your computer and use it in GitHub Desktop.
Save yssk22/5524656 to your computer and use it in GitHub Desktop.
うごかないぉ
package main
import (
"log"
"syscall"
"os"
"os/signal"
"time"
)
func loop(s string, wait time.Duration) {
for {
log.Printf("[%s] foo", s)
time.Sleep(wait)
log.Printf("[%s] bar", s)
time.Sleep(1 * time.Second)
}
}
func main() {
d := 2200000 * time.Hour
log.Printf("%d", d)
go loop("111", d)
go loop("222", 1 * time.Second)
sig := make(chan os.Signal)
signal.Notify(sig, syscall.SIGINT)
signal.Notify(sig, syscall.SIGTERM)
s := <-sig
log.Printf("Exited with %d", s)
}
@yssk22
Copy link
Author

yssk22 commented May 6, 2013

expected

2013/05/06 20:40:07 [111] foo
2013/05/06 20:40:07 [222] foo
2013/05/06 20:40:08 [222] bar
2013/05/06 20:40:09 [222] foo
2013/05/06 20:40:10 [222] bar
2013/05/06 20:40:11 [222] foo
2013/05/06 20:40:12 [222] bar
2013/05/06 20:40:13 [222] foo
2013/05/06 20:40:14 [222] bar

but 222 loop cannot work failed if d is a large value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment