[Interest] how to run 21 threads concurrently

Sujan Dasmahapatra sujan.dasmahapatra at gmail.com
Thu Oct 4 23:35:44 CEST 2012


which loop?
for(int th=0; th<Threads.size(); th++)
{
if(Threads[th].isRunning())
Threads[th].waitForFinished();
Threads[th].cancel();
}
Threads.clear();

This loop is correct. If threads is running wait, then cancel it. braces
are proper Sascha.

On Thu, Oct 4, 2012 at 8:14 PM, Sascha Cunz <sascha-ml at babbelbox.org> wrote:

> Hi Sujan,
>
> your threads don't output all data to disk, because you forgot some curly
> braces in the second loop.
>
> Sascha
>
> Am Donnerstag, 4. Oktober 2012, 16:21:10 schrieb Sujan Dasmahapatra:
> > 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<void> > Threads;
> > QFuture<void> Th;
> >
> > for(int z=0; z<21; z++)
> > {
> > Th = QtConcurrent::run(this,&UnrstParser,z);
> > Thraeds.push_back(Th);
> > }
> > for(int th=0; th<Threads.size(); 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 at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



-- 
Regards
Sujan Dasmahapatra
skype: sujan.dasmahapatra
yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
Mobile no : +966-530184511
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121005/426926bf/attachment.html>


More information about the Interest mailing list