SJ, If what you're asking is whether the tasks will be evenly spread among the goroutines, the answer is no. You can't guarantee such an even distribution, though over time with many more tasks than threads, all taking approximately the same amount of time, I assume you'd see a mostly smooth division of work. 2 concurrency with 20 tasks would likely be a more even division, for example.
Part of the issue you might be having is that the variable, 'i', in your code, references the value in the for loop, and therefore changes as the for loop iterates. That means that you can't use it as a goroutine identifier, which I think is your intent. Instead, you'll need to create a variable INSIDE the for loop and reference that one instead. You'll sometimes see tricks like this inside a for loop that spawns goroutines: i := i Compare https://play.golang.org/p/lGVAlVmjh7 versus https://play.golang.org/p/VO1ra_JUWs That will create a fresh local variable, which is safely usable as a goroutine identifier. A better (in my opinion) alternative is to provide an input into the goroutine and explicitly pass the current value of 'i': go func(i int) { ... }(i) It would be better still to call the goroutine's parameter something other than 'i'. Bob -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.