Thanks andre for your reply. Can u give me some sample code of using QThreadPool. Can u refer my code snippet how i can implement the same function which is being called 21 times for 21 z values......How to run them parallely using QThreadPool. Some code snippet will be fine so that I get some idea. Thanks Sujan
Op 4-10-2012 15:21, Sujan Dasmahapatra schreef: > > > > 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. > > > > > QtConcurrent will use as many threads as it deems useful, based on the > system you are running on. Unless you have a 21 core system, it is > probably not useful to run 21 threads your your task. > However, QThreadPool has methods to change how many threads are > considdered useful, so you should look into using that class. > > André > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > -- Regards Sujan Dasmahapatra skype: sujan.dasmahapatra yahoo msn : dasmahapatra.aerodynam...@yahoo.co.in Mobile no : +966-530184511
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest