网站开发 安全合同中国工商注册网企业年报系统

张小明 2026/1/1 7:21:21
网站开发 安全合同,中国工商注册网企业年报系统,网站设计服务费英文,wordpress get attachment.h代码示例 #ifndef THREAD_14_2_3_H #define THREAD_14_2_3_H/* 功能描述#xff1a;使用三个线程 分别对公共资源进行操作 三个thread分别是一个生产者 两个消费者 写入#xff1a; 将自己的资源写入公共资源中去 thread#xff1a;str1 保存的来自公共资源 threadmain使用三个线程 分别对公共资源进行操作 三个thread分别是一个生产者 两个消费者 写入 将自己的资源写入公共资源中去 threadstr1 保存的来自公共资源 threadmainstr公共资源 被其他资源读时 可以 但是不能一读一写。 规定 thread1 是生产者 thread 2 3 是消费者 */#includeQWidget#includeQPushButton#includeQHBoxLayout#includeQVBoxLayout#includeQReadLocker#includeQWriteLocker#includeQLabel#includeQPlainTextEdit#includeQThread#includeQMutex#includeQReadWriteLock#includeQTimeclassthreads;/* 生产者功能 添加对buff进行添加 展示buff 里面都有什么东西 */classthread1:publicQThread{Q_OBJECTpublic:thread1(threads*parent);~thread1();public:voidrun()override;public:QString str1生产者thread;threads*parent;voidwrite();signals:voidwritetext(QString str);};/* 消费者 从这里面读取资源*/classthread2:publicQThread{Q_OBJECTpublic:thread2(threads*parent);~thread2();public:voidrun()override;public:QString str1读者线程2:;threads*parent;signals:voidwritetext(QString str);};classthread3:publicQThread{Q_OBJECTpublic:thread3(threads*parent);~thread3();public:voidrun()override;public:QString str1读者线程3;threads*parent;signals:voidwritetext(QString str);};classthreads:publicQWidget{Q_OBJECTpublic:threads(QWidget*parentnullptr);~threads();private:QPushButton*btnThread1Readnullptr;QPushButton*btnThread1Writenullptr;QLabel*thread1Labelnullptr;QPlainTextEdit*thread1Textnullptr;QLabel*thread2Labelnullptr;QPushButton*btnThread2Readnullptr;QPlainTextEdit*thread2Textnullptr;QLabel*thread3Labelnullptr;QPushButton*btnThread3Readnullptr;QPlainTextEdit*thread3Textnullptr;QHBoxLayout*tophlaynullptr;QHBoxLayout*centerhlaynullptr;QHBoxLayout*bottomhlaynullptr;QVBoxLayout*vlaynullptr;voidsetui();privateslots:voidreadthread1();voidwritethread1();voidreadthread2();voidreadthread3();voidprinttext(QString str1);private:voidconnectSignals();public:thread1*t1newthread1(this);thread2*t2newthread2(this);thread3*t3newthread3(this);enumStatue{stopped,running,paused};Statue statuepaused;private:QMutex mutex;public:QString buff1公共资源buff ;QReadWriteLock lock;};#endif// THREAD_14_2_3_H###代码.cpp#includethread_14_2_3.h#includeQString#includeQTimerthreads::threads(QWidget*parent):QWidget{parent}{setui();connectSignals();t1-start();t2-start();t3-start();}threads::~threads(){this-statuestopped;t1-quit();t1-wait();t2-quit();t2-wait();t3-quit();t3-wait();}voidthreads::setui(){QSize btnSize{60,30};btnThread1ReadnewQPushButton(this);btnThread1Read-setMinimumSize(btnSize);btnThread1Read-setText(读取);thread1LabelnewQLabel(this);thread1Label-setText(thread1);btnThread1WritenewQPushButton(this);btnThread1Write-setMinimumSize(btnSize);btnThread1Write-setText(写入buff1);thread1TextnewQPlainTextEdit(this);btnThread2ReadnewQPushButton(this);btnThread2Read-setMinimumSize(btnSize);btnThread2Read-setText(读取);thread2LabelnewQLabel(this);thread2Label-setText(thread2);thread2TextnewQPlainTextEdit(this);btnThread3ReadnewQPushButton(this);btnThread3Read-setMinimumSize(btnSize);btnThread3Read-setText(读取);thread3LabelnewQLabel(this);thread3Label-setText(thread3);thread3TextnewQPlainTextEdit(this);tophlaynewQHBoxLayout();centerhlaynewQHBoxLayout();bottomhlaynewQHBoxLayout();tophlay-addWidget(thread1Label);tophlay-addWidget(btnThread1Read);tophlay-addWidget(btnThread1Write);tophlay-addWidget(thread1Text);centerhlay-addWidget(thread2Label);centerhlay-addWidget(btnThread2Read);centerhlay-addWidget(thread2Text);bottomhlay-addWidget(thread3Label);bottomhlay-addWidget(btnThread3Read);bottomhlay-addWidget(thread3Text);vlaynewQVBoxLayout(this);vlay-addLayout(tophlay);vlay-addLayout(centerhlay);vlay-addLayout(bottomhlay);this-setLayout(vlay);}//写线程 展示所有的线程的资源voidthreads::readthread1(){lock.tryLockForRead(1000);QString strallQString(buff1:%1\nthread1:%2\n读线程thread2:%3\n读线程thread3:%4).arg(buff1).arg(t1-str1).arg(t2-str1).arg(t3-str1);thread1Text-appendPlainText(strall);lock.unlock();}//写线程 把 编辑框里面的内容 写入t1内voidthreads::writethread1(){lock.lockForWrite();QString str1thread2Text-toPlainText();t1-str1str1;t1-write();thread3Text-appendPlainText(QString(正在写入---buff1%1).arg(str1));QThread::msleep(700);//模拟5s的时间写入时间lock.unlock();}//thread2 读公共资源到自己的成员中voidthreads::readthread2(){// thread3Text-appendPlainText(QString(正在尝试读取-buff1上锁\n));// if(lock.tryLockForRead())// {// t2.str1 buff1;// thread3Text-appendPlainText(QString(thread2正在读取---buff1%1).arg(t2.str1));// lock.unlock();// return;// }// thread3Text-appendPlainText(QString(thread2读取失败---str%1).arg(t2.str1));}voidthreads::readthread3(){// thread3Text-appendPlainText(QString(正在尝试读取-buff1上锁\n));// if(lock.tryLockForRead())// {// t3.str1 buff1;// thread3Text-appendPlainText(QString(thread3正在读取---buff1%1).arg(t3.str1));// lock.unlock();// }// thread3Text-appendPlainText(QString(thread3读取失败---str%1).arg(t3.str1));}voidthreads::printtext(QString str1){thread3Text-appendPlainText(str1);}voidthreads::connectSignals(){connect(btnThread1Read,QPushButton::clicked,this,threads::readthread1);connect(btnThread2Read,QPushButton::clicked,this,threads::readthread2);connect(btnThread3Read,QPushButton::clicked,this,threads::readthread3);connect(btnThread1Write,QPushButton::clicked,this,threads::writethread1);connect(t1,thread1::writetext,this,threads::printtext);connect(t2,thread2::writetext,this,threads::printtext);connect(t3,thread3::writetext,this,threads::printtext);}thread1::thread1(threads*parent):parent(parent){}thread1::~thread1(){}voidthread1::run(){while(1){msleep(1000);qDebug()报告长官生产者thread1号正在生产;parent-lock.lockForWrite();QString str1QTime::currentTime().toString();parent-buff1str1;QString allQString(%1写入成功).arg(str1);emitwritetext(all);msleep(300);parent-lock.unlock();if(parent-statuethreads::stopped)break;}}voidthread1::write(){parent-buff1this-str1;}thread2::thread2(threads*parent):parent(parent){}thread2::~thread2(){}voidthread2::run(){while(1){msleep(500);QString str读取失败 芜湖 起飞;qDebug()报告长官消费者thread2号正在读取;if(parent-lock.tryLockForRead(50)){strparent-buff1;this-str1str;QString allQString(%1读取成功).arg(str);emitwritetext(all);msleep(300);parent-lock.unlock();}else{emitwritetext(str);msleep(150);}if(parent-statuethreads::stopped)break;}}thread3::thread3(threads*parent):parent(parent){}thread3::~thread3(){}voidthread3::run(){while(1){msleep(500);QString str读取失败 芜湖 起飞;qDebug()报告长官消费者thread3号正在读取;if(parent-lock.tryLockForRead(50)){strparent-buff1;this-str1str;QString allQString(%1读取成功).arg(str);emitwritetext(all);msleep(300);parent-lock.unlock();}else{emitwritetext(str);msleep(150);}if(parent-statuethreads::stopped)break;}}
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

婚礼纪网站怎么做请帖手机网站设计只选亿企邦

ComfyUI中文界面设置与本地部署全指南 在AI生成内容(AIGC)迅速普及的今天,越来越多创作者希望摆脱“黑箱式”工具的束缚——那些只能输入提示词、点击生成、结果难以复现的传统WebUI。如果你也曾为无法精准控制图像生成流程而困扰&#xff0c…

张小明 2025/12/30 9:14:04 网站建设

q王商城 网站是怎么做的Wordpress api开发

Langchain-Chatchat 如何实现离线问答?技术架构深度解析 在企业对数据隐私和系统可控性要求日益提升的今天,一个能“闭门造车”的智能问答系统变得极具吸引力。想象这样一个场景:HR 员工不再翻找冗长的制度文件,只需一句“新员工什…

张小明 2025/12/26 3:23:36 网站建设

网站升级方案wordpress邀请会员

iOS降级作为移动设备逆向工程领域的重要技术,为开发者和技术爱好者提供了突破系统限制的可能。LeetDown作为一款专门针对A6和A7架构iOS设备的macOS平台降级工具,通过创新的技术实现和稳定的架构设计,为这一复杂任务提供了可靠的解决方案。 【…

张小明 2025/12/23 15:57:23 网站建设

域名备案好了怎么建设网站百度下载安装到手机

在数字化转型浪潮中,企业每天处理的海量文档已成为效率瓶颈。DeepSeek-OCR以"视觉即压缩"的创新理念,通过仅100个视觉token实现传统OCR模型7000文本token的文档解析效果,为多模态文档处理带来革命性突破。 【免费下载链接】DeepSee…

张小明 2026/1/1 0:37:02 网站建设

网站建设纳千网络wordpress不锈钢企业

VS Code写作助手:Grammarly插件完整使用手册 【免费下载链接】grammarly Grammarly for VS Code 项目地址: https://gitcode.com/gh_mirrors/gr/grammarly Grammarly for VS Code是专为开发者设计的智能语法检查工具,将专业的写作辅助功能无缝集成…

张小明 2025/12/31 13:39:47 网站建设

暗网做网站美团网站网站建设发展

在当下的电商环境形势里,小程序商城已然变成品牌数字化经营的关键重要基础性设施。对于那些寻觅数字化转型的商家来讲,挑选一个技术稳定、功能全面并且拥有高性价比的服务商是极其关键重要的。本文会依据客观实际来梳理市场上几家主流小程序商城服务商的…

张小明 2025/12/23 15:52:11 网站建设