I would also add a small sleep to the worker thread's event loop, so that it doesn't gobble all the cpu power and gives the main thread a chance to perform normally.
void myClassThread::run()
{
while(!bFinish)
{
//Do some work
msleep(10);
}
//It will exit "while" when "bFinish" is true, so then the "run" method will exit and so the thread will stop
}
void myClassThread::run()
{
while(!bFinish)
{
//Do some work
msleep(10);
}
//It will exit "while" when "bFinish" is true, so then the "run" method will exit and so the thread will stop
}
To copy to clipboard, switch view to plain text mode
Bookmarks