Skip to content

Instantly share code, notes, and snippets.

@dgrijalva
Created November 14, 2011 19:26
Show Gist options
  • Save dgrijalva/1364867 to your computer and use it in GitHub Desktop.
Save dgrijalva/1364867 to your computer and use it in GitHub Desktop.
Runaway deadlocked goroutines
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
go count()
for {
spawn()
time.Sleep(1e9)
}
}
func count() {
for {
fmt.Printf("Currently running %v goroutines\n", runtime.Goroutines())
time.Sleep(1e9)
}
}
func spawn() {
c := make(chan int, 1)
go wait(c)
}
func wait(c chan int) {
<- c
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment