The code is like this:
func find(start int, end int){
for i := start; i < end ; i++ {
// Do something...
}
}
func main() {
// Do something...
// For example, I know: len = 1500
// and run max goroutine are 3
// will be
go find(0, 500)
go find(500, 1000)
go find(1000, 1500)
// Do something...
}
That is when I know in advance the maximum threads of goroutines and the length of "length". But if I do not know how many threads can run at goroutine, and the length of "length". Is there any way to divide "length" into equal sections for thread processing? For example: length = 10, max goroutine that can run is 2 and it will split length into 2 threads (10/2, each length is 5) to be able to handle simultaneously.