On Wed, Jun 21, 2017 at 1:50 PM Ronald <yunthana...@gmail.com> wrote:

> for {
>         ct++
>         if ct%600000000 == 0 {
>                 t2 := time.Now().UnixNano()
>                 fmt.Println("hooray", t2, t1, float64(t2-t1)/1e6)
>                 t1 = t2
>         }
> }

> This piece code is not "dead spin", it is just cpu intensive.

This piece of code prohibits cooperative scheduling in 599 999 999 out of
600 000 000 times. It's a nice example how to not code in Go. Particularly,
delays should be implemented using the functions in the time package, not
by burning CPU cycles at the expense of other useful work that could have
been done instead.

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to