title: all goroutines are asleep - deadlock
body: <p>For one of my requirement I have to create N number of worker go routines, which will be monitored by one monitoring routine. monitoring routine has to end when all worker routines completes. My code ending in deadlock, please help.</p>
  
  <pre><code>import "fmt"
  import "sync"
  import "strconv"
  
  func worker(wg *sync.WaitGroup, cs chan string, i int ){
      defer wg.Done()
      cs&lt;-"worker"+strconv.Itoa(i)    
  }
  
  func monitorWorker(wg *sync.WaitGroup, cs chan string) {
      defer wg.Done()
      for i:= range cs {
              fmt.Println(i)
       }
  }
  func main() {
      wg := &amp;sync.WaitGroup{}
      cs := make(chan string)
  
      for i:=0;i&lt;10;i++{
               wg.Add(1)
               go worker(wg,cs,i)
      } 
  
      wg.Add(1)
      go monitorWorker(wg,cs)
      wg.Wait()
  }
  </code></pre>