How can I utilize all cores of CPU In my ray tracer with std::thread?
This is not really a CG issue but you appear to have an integer division problem. Assuming mMaxThreads is an integer,  (threadIndex / mMaxThreads) is always 0 and ((threadIndex + 1) / mMaxThreads) is 0 for all threads but the last one, where it is 1. So one thread is doing all the work.