void QThread::run(){ (void) exec();}
void QThread::start(Priority priority){ Q_D(QThread); QMutexLocker locker(&d->mutex); if (d->isInFinish) { locker.unlock(); wait(); locker.relock(); } if (d->running) return; d->running = true; d->finished = false; d->terminated = false; d->exited = false; d->returnCode = 0; d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start, this, CREATE_SUSPENDED, &(d->id)); if (!d->handle) { qErrnoWarning(errno, "QThread::start: Failed to create thread"); d->running = false; d->finished = true; return; } int prio; d->priority = priority; switch (d->priority) { case IdlePriority: prio = THREAD_PRIORITY_IDLE; break; case LowestPriority: prio = THREAD_PRIORITY_LOWEST; break; case LowPriority: prio = THREAD_PRIORITY_BELOW_NORMAL; break; case NormalPriority: prio = THREAD_PRIORITY_NORMAL; break; case HighPriority: prio = THREAD_PRIORITY_ABOVE_NORMAL; break; case HighestPriority: prio = THREAD_PRIORITY_HIGHEST; break; case TimeCriticalPriority: prio = THREAD_PRIORITY_TIME_CRITICAL; break; case InheritPriority: default: prio = GetThreadPriority(GetCurrentThread()); break; } if (!SetThreadPriority(d->handle, prio)) { qErrnoWarning("QThread::start: Failed to set thread priority"); } if (ResumeThread(d->handle) == (DWORD) -1) { qErrnoWarning("QThread::start: Failed to resume new thread"); }}