When is a thread garbage collected?

Kent Johnson kent37 at tds.net
Wed Mar 16 14:43:21 EST 2005


If I create and start a thread without keeping a reference to the thread, when is the thread garbage 
collected?

What I would like is for the thread to run to completion, then be GCed. I can't find anything in the 
docs that specifies this behavior; nor can I think of any other behaviour that seems reasonable :-)

For example with this code:

def genpassenger(num):
     for i in range(num):
         passenger().start()

class passenger(threading.Thread):
         def run:
             #do something

will all the passenger threads run to completion, then be GCed?

Thanks,
Kent



More information about the Python-list mailing list