C++ (Qt)void Widget::createThread(){ ... thread = new Thread(); thread->start(); } void Widget::~Widget(){ if(thread->isRunning()){ thread->quit(); thread->wait(); thread->deleteLater(); }}
C++ (Qt)void Thread::run(){ forever(){ qDebug()<<"Thread"; funcWait(20); //20 msec }}
C++ (Qt)void Widget::createThread(){ ... thread = new Thread(); thread->threadStart = true; thread->start(); } void Widget::~Widget(){ if(thread != NULL){ thread->startThread = false thread->quit(); thread->wait(); thread->deleteLater(); void Thread::run(){ forever(){ if(!threadStart){ break; } ...}
C++ (Qt) if(thread != NULL){ thread->startThread = false thread->quit(); thread->wait(); thread->deleteLater();
delete...
...->deleteLater();