【发布时间】:2013-06-18 14:56:00
【问题描述】:
我正在寻找一些关于使用QThreadPool 的简洁示例。以下是我的使用方法:
QThreadPool *thread_pool = QThreadPool::globalInstance();
MyThread *thread = new MyThread();
thread_pool->start(thread);
class MyThread : public QRunnable {
public:
MyThread();
~MyThread();
void run();
};
void MyThread::run()
{
qDebug() << "MyThread";
}
以上做法正确吗?
PS:我在参考文献中看到了waitForDone,什么时候应该调用waitForDone?
【问题讨论】:
标签: c++ multithreading qt threadpool