C++ (Qt)QEventLoop eventLoop;while(true){ eventLoop.processEvents(); //ультранужная задача}
C++ (Qt)void QThread::run(){ (void) exec();}
C++ (Qt)int QThread::exec(){ Q_D(QThread); QMutexLocker locker(&d->mutex); d->data->quitNow = false; if (d->exited) { d->exited = false; return d->returnCode; } locker.unlock(); QEventLoop eventLoop; int returnCode = eventLoop.exec(); locker.relock(); d->exited = false; d->returnCode = -1; return returnCode;}
void run() { while (true) { Sleep(10); } };
class SBFiber : public QThread{ Q_OBJECTpublic: SBFiber(QObject *parent = 0); ~SBFiber(); void run() { connect(this, SIGNAL(sig()), SLOT(slot())); while (true) { emit sig(); Sleep(10); } }; public slots: void slot() { qDebug() << "fdsfdf"; };signals: void sig();private: };