diff --git a/multi-threading/fibonacci-multi-threaded.go b/multi-threading/fibonacci-multi-threaded.go index c3b86b4..badca94 100644 --- a/multi-threading/fibonacci-multi-threaded.go +++ b/multi-threading/fibonacci-multi-threaded.go @@ -56,13 +56,11 @@ func main() { } // Send tasks to the task channel - for i := 1; i <= numTasks; i++ { - n := rand.Intn(maxFib - minFib) - tasks <- Task{id: i, n: 30} // n=30 is computationally intensive for Fibonacci - } - + for i := 1; i <= numTasks; i++ { n := rand.Intn(maxFib - minFib) // Random number between minFib and maxFib tasks <- Task{id: i, n: n} + } + // Close the task channel to signal no more tasks close(tasks)