Question about thread

Valkyrie valkyrie at cuhk.edu.hk
Sat Nov 20 05:27:05 CET 2004


So may I ask is threading do exactly the same in terms of functionalities as 
those in thread?


Jarek Zgoda wrote:
> Diez B. Roggisch wrote:
> 
>>> Even after printing "finished creating threads" all spawned threads
>>> continue its execution up to final "thread nnnn is being destroyed", so
>>> I think there's no need to take any special action (unless it's Python
>>> on iSeries, buy this is another story) to wait for completion.
>>
>>
>> The OP used the module "thread", while you used "threading" and didn't 
>> set
>> setDaemon(False). Then python waits until all threads are finished.
> 
> 
> Well... I was bit too fast in replying. ;)
> 
>> From the thread module docs:
>>
>> When the main thread exits, it is system defined whether the other 
>> threads
>> survive. On SGI IRIX using the native thread implementation, they 
>> survive.
>> On most other systems, they are killed without executing try ... finally
>> clauses or executing object destructors.   
> 
> 
> So it looks that using threading should be preferred over using thread, 
> as presented example works identically on Windows and on linux (it 
> doesn't work on AS/400, though...).
> 



More information about the Python-list mailing list