全面解析 Qt 的线程机制及其实现细节 Qt 多线程开发实践
发布时间
阅读量:
阅读量
参考资料综述
- http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-1/
- http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-2/
说明:在线程并发处理的程序结构中,线程可划分为两类,即主控线程(main thread)与执行任务的辅助线程(worker thread)
run() 函数是QThread 类的入口
#include <QtCore>
class Thread : public QThread
{
private:
void run()
{
qDebug()<<"From worker thread: "<<currentThreadId();
}
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug()<<"From main thread: "<<QThread::currentThreadId();
全部评论 (0)
还没有任何评论哟~
