[Qt-interest] QThread reinitialization

Bradley T. Hughes bradley.hughes at nokia.com
Fri Jun 5 10:18:55 CEST 2009


Ingomar Wesp wrote:
>>> I have a question regarding QThread. Let say we have a QThread object.
>>> We start the thread. After the run() method finishes, can we again call
>>> the "start()" method ? Or we have to create a new object and then start
>>> the method again.
>> Calling start() again is perfectly possible.
> 
> Just curious: Is the underlying (native) thread destroyed when the run() 
> method terminates? That is: Does calling start() again require a new native 
> thread to be created (and is thus expensive in terms of performance)?

Yes, it is. Both pthread and Win32 threads cannot be restarted, so QThread 
will create new OS threads each time start() is called.

-- 
Bradley T. Hughes (Nokia-D-Qt/Oslo), bradley.hughes at nokia.com
Sandakervn. 116, P.O. Box 4332 Nydalen, 0402 Oslo, Norway



More information about the Qt-interest-old mailing list