QT Thread 练习Demo

 

 1 #ifndef THREADTEST1_H
 2 #define THREADTEST1_H
 3 
 4 #include <QObject>
 5 #include <QThread>
 6 #include <QDebug>
 7 #include <QRandomGenerator>
 8 #include <QWaitCondition>
 9 #include <QMutex>
10 #include <QSemaphore>
11 
12 class ThreadTest1 : public QThread
13 {
14     Q_OBJECT
15 public:
16     ThreadTest1(int _index, QWaitCondition *_condition, QMutex *_mutex, QSemaphore *_semaphore, QObject *parent = nullptr);
17     ~ThreadTest1();
18 signals:
19     void updateProgress(int);
20 
21 public:
22     void doSomething();
23 
24     void run() override;
25 
26     QWaitCondition *condition;
27     QMutex *mutex;
28     QSemaphore *semaphore;
29     int index;
30 
31 private:
32     int nProgress = 0;
33     QRandomGenerator *generator = QRandomGenerator::global();
34 
35 };
36 
37 #endif // THREADTEST1_H
threadtest1.h

相关文章:

  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2021-09-02
  • 2022-12-23
  • 2021-10-27
  • 2022-12-23
相关资源
相似解决方案