Resovled the issue that when number of tasks is fewer than cores, we end up creating as many threads as the number of cores, making the performance worse than the single thread version.
Resovled the issue that when number of tasks is fewer than cores, we end up creating as many threads as the number of cores, making the performance worse than the single thread version.