您当前的位置: 首页 >  c++

命运之手

暂无认证

  • 1浏览

    0关注

    747博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

【零基础学QT】【038】Qt多线程框架和C++11多线程框架

命运之手 发布时间:2019-12-17 15:52:25 ,浏览量:1

使用QThread实现多线程


	#include "qlib.h"
	
	class PrintThread : public QThread {
	  private:
	    //通过bool来控制运行条件
	    bool running = true;
	
	  public:
	    PrintThread() {}
	    //在析构函数中自动结束线程
	    //很重要,可以在主线程结束时,保证子线程正常结束
	    ~PrintThread() {
	        running = false;
	        this->requestInterruption();
	        this->wait();
	    }
	
	  protected:
	    //重写run方法,指定线程工作
	    void run() {
	        while (running) {
	            wcout  void {
	        while (t->isRunning()) {
	            wcout isRunning()) {
	            wcout             
关注
打赏
1654938663
查看更多评论
0.0427s