question about threads: calling 'start()->"
Hi,
i was wondering something about threads :
if you initalize your class, and then you call its instance with "start()", won't this class be called two times, once for the instance, and the second time for the thread pool? (whereas we just want to call the class once, on a separate thread)
example :
Code:
void MyClient::readyRead(){
MyTask *mytask = new MyTask();
…
QThreadPool::globalInstance()->start(mytask);
}
Thanks
Re: question about threads: calling 'start()->"
Hi,
Why you just not use QThread. For example:
Code:
class myBigProcess
: public QThread{
Q_OBJECT
public:
explicit myBigProcess
(QObject *parent
= 0);
void run();
};
Code:
myBigProcess
::myBigProcess(QObject *parent
) :{
}
void myBigProcess::run()
{
///Massive process here
}
Then you can do:
Code:
myBigProcess *MBP;
MBP = new myBigProcess(this);
MBP->start(); //This will call run();
QThread has signals to know when the run() finished.
Carlos.
Re: question about threads: calling 'start()->"
QThreadPool::start starts a run method on the passed object and initializes it does not.
Re: question about threads: calling 'start()->"
oh okay, thanks for your answers