Do not limit number of available threads by number of items processed within the root scope due to possibility of spawning of an additional threads within the subscopes.
{
const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
const Standard_Integer aNbThreads = theNbItems > 0 ?
- Min (theNbItems, aThreadPool->NbDefaultThreadsToLaunch()) : -1;
+ aThreadPool->NbDefaultThreadsToLaunch() : -1;
tbb::task_scheduler_init aScheduler (aNbThreads);
tbb::parallel_for_each (theBegin, theEnd, theFunctor);