New gopher.
Is this block-channel makes goroutine synchronized?
Is this a better way?
children_quits := make(chan bool, len(urls))
for _, url := range urls {
go RCrawl(url, depth-1, fetcher, children_quits)
}
for i := 0; i < len(urls); i++ {
<-children_quits
}
I think you are right. The original code is not concurrent. The for loop will not step until current RCrawl finishes, so there is only one goroutine running at any moment.
https://github.com/AntoineAugusti/go-exercices/blob/f28113ebe9f41e12a6ea80da08dbc6d484f1763a/12-exercise-web-crawler.go#L53
New gopher. Is this block-channel makes goroutine synchronized?
Is this a better way?