Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtCore>
- class Thread : public QThread
- {
- public:
- Thread(int m) : m(m) {}
- protected:
- virtual void run()
- {
- sleep(m);
- qDebug() << m;
- }
- private:
- int m;
- };
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- QList<Thread *> list;
- foreach (const QString &s, a.arguments()) {
- bool ok;
- int n = s.toInt(&ok);
- if (ok) {
- Thread *t = new Thread(n);
- t->start();
- list << t;
- }
- }
- foreach (Thread *t, list)
- t->wait();
- qDeleteAll(list);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement