Apply maxThreads based on ncpus in dynamic templates