I'm not sure why you would want to run 21 threads that are writing files on an 8 core machine. Depending on the OS, it is likely you will start time slicing which can actually be slower than waiting for a thread to finish before starting another one. Since you are writing files, the Disk I/O is likely going to be your main overhead and, depending on the OS and hardware architecture, it is likely that more threads will simply cause more movement of disk heads which would likely slow the program down. (Unless you have flash storage or some other solid state storage device.)
I would suggest removing the "Threads[th].cancel();" line and let QtConcurrent do its thing with your threads. I've found trying to out perform QtConcurrent to be a challenge in most cases. Karl On 2012-10-04 07:21, Sujan Dasmahapatra wrote: > I am not able to run my threads concurrently please help. > How can I run 21 threads concurrently and get the job done by 8 cpus what I have in my machine. > > I am doing like this > [code] > > std::vector> Threads; > QFuture Th; > > for(int z=0; z{ > Th = QtConcurrent::run(this,&UnrstParser,z); > Thraeds.push_back(Th); > } > for(int th=0; th{ > if(Threads[th].isRunning()) > Threads[th].waitForFinished(); > Threads[th].cancel(); > } > Threads.clear(); > [/code] > > With this first few threads are probably running but not all the threads. As it's supposed to generate some files by each thread which is not being generated. Please help.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest