voidQthread::run () {(void) exec ();}intqthread::exec () {q_d (qthread); Qmutexlocker Locker (&d->mutex); D->data->quitnow =false; if(d->exited) {D->exited =false; returnD->ReturnCode; } locker.unlock (); Qeventloop EventLoop; intReturnCode =eventloop.exec (); Locker.relock (); D->exited =false; D->returncode =-1; returnReturnCode;}voidQthread::exit (intReturnCode) {q_d (qthread); Qmutexlocker Locker (&d->mutex); D->exited =true; D->returncode =ReturnCode; D->data->quitnow =true; for(inti =0; I < d->data->eventloops.size (); ++i) {qeventloop*eventloop = d->data->eventloops.at (i); EventLoop-exit (ReturnCode); }}/*! Tells the thread ' s event loop to exit with return code 0 (success). Equivalent to calling Qthread::exit (0). This function does nothing if the thread does not has an event loop. \sa exit (), Qeventloop*/voidQthread::quit () {exit ();}
Https://github.com/openwebos/qt/blob/master/src/corelib/thread/qthread.cpp
Qthread Source (Direct search "thread.cpp" can be, or on GitHub search)