Threads: does Thread.start() atomically set Thread.__started ?

Enigma Curry workbee at
Tue Mar 14 23:59:18 CET 2006

Can some kind person please further my education on Threads?

When I create a thread called "t" and I do a "t.start()" am I
guaranteed that "t.isAlive()" will return True as long as the thread
hasn't already completed? Put another way, does "t.start()" ever return
before t.__started is set to True?

consider this example:

import time
import threading
class MyThread(threading.Thread):
    def __init__(self):
        self.completed = False
    def run(self):
        #do something
        self.completed = True

t = MyThread()
while t.isAlive() == False and t.completed == False:

In the above code, am I guaranteed that t will only be (attempted to
be) started once?


More information about the Python-list mailing list