title: Loop in goroutine hangs program
body: <p>Why does the following program hang when the <code>time.Sleep(time.Nanosecond)</code> is commented out?</p>
  
  <pre><code>package main
  
  import "fmt"
  import "time"
  import "sync/atomic"
  
  func main() {
      var ops uint64 = 0
      for i := 0; i &lt; 50; i++ {
          go func() {
              for {
                  atomic.AddUint64(&amp;ops, 1)
                  time.Sleep(time.Nanosecond)
              }
          }()
      }
  
      time.Sleep(time.Millisecond)
      opsFinal := atomic.LoadUint64(&amp;ops)
      fmt.Println("ops:", opsFinal)
  }
  </code></pre>
  
  <p>Second question, why does <a href="https://play.golang.org/p/lnl5qxRfit" rel="nofollow noreferrer">running this program in the sandbox</a> result in "process took too long"?</p>