diff --git a/examples/timers/timers.go b/examples/timers/timers.go index d63c48f..8e6da27 100644 --- a/examples/timers/timers.go +++ b/examples/timers/timers.go @@ -39,6 +39,10 @@ func main() { fmt.Println("Timer 2 stopped") } - // Give timer2 enough time if it has to expire. - time.Sleep(2) + // Main routine might finish well before the above + // go-routine, in such case timer2 may not get a + // chance to expire. So, lets put the main routine + // to sleep for 2 seconds giving timer2 enough time + // to expire or stop properly. + time.Sleep(2 * time.Second) } diff --git a/examples/timers/timers.hash b/examples/timers/timers.hash index a0a49de..84b0982 100644 --- a/examples/timers/timers.hash +++ b/examples/timers/timers.hash @@ -1,2 +1,2 @@ -4344f155c91037a32ce8e32489598c1216a242f3 -zUBjU4lkedA +50aabaa95bcd96ecaa6259e2b4ccb199cacdb290 +RGYyK5ULk-t diff --git a/public/timers b/public/timers index 5bae0c7..d29e6ab 100644 --- a/public/timers +++ b/public/timers @@ -45,7 +45,7 @@ at tickers.

- +
package main
 
@@ -137,12 +137,16 @@ Here’s an example of that.

-

Give timer2 enough time if it has to expire.

+

Main routine might finish well before the above +go-routine, in such case timer2 may not get a +chance to expire. So, lets put the main routine +to sleep for 2 seconds giving timer2 enough time +to expire or stop properly.

-
    time.Sleep(2)
+          
    time.Sleep(2 * time.Second)
 }
 
@@ -183,7 +187,7 @@ a chance to expire.