[Interest] how to run 21 threads concurrently

Karl Ruetz karl.ruetz at ruetzdogz.com
Thu Oct 4 16:16:34 CEST 2012


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. 


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>
> QFuture Th; 
> for(int z=0; z{
> Th =
> Thraeds.push_back(Th);
> }
for(int th=0; th{
> if(Threads[th].isRunning())
> Threads[th].cancel();
> }
> [/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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121004/0609be8a/attachment.html>

More information about the Interest mailing list