Multiple start() on same QThread Object
Hi all,
can I run multiple start() method on same QThread object ?
Simple example follows:
Code:
int main(int argc, char *argv[]){
threadHandler *TH=new threadHandler();
TH.start()
TH.start()
return app.exec();
}
This code executes the two run() methods as two serial executions.
Is this correct? Do you have experience in this?
Thanks,
Michele
Re: Multiple start() on same QThread Object
No, only the first call will be effective.
If you call start() a second time while the thread is running, it will do nothing !
http://doc.trolltech.com/4.2/qthread.html#start
Re: Multiple start() on same QThread Object
You can use the same class, but two objects, to get two threads. Myabe this is what you want.
Re: Multiple start() on same QThread Object
Quote:
Originally Posted by
guilugi
Am I correct if I suppose this means that start() can be called several times IF the run() method has returned between the calls?
Re: Multiple start() on same QThread Object
Yes, you can start the thread again when it has already finished.