Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make goroutine synchronized? #2

Open
u2386 opened this issue Jul 6, 2018 · 1 comment
Open

Make goroutine synchronized? #2

u2386 opened this issue Jul 6, 2018 · 1 comment

Comments

@u2386
Copy link

u2386 commented Jul 6, 2018

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
}
@lsdsjy
Copy link

lsdsjy commented Nov 1, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants