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(thread ing.Thread):
def __init__(self):
self.completed = False
threading.Threa d.__init__(self )
def run(self):
#do something
time.sleep(1)
self.completed = True
t = MyThread()
while t.isAlive() == False and t.completed == False:
t.start()
In the above code, am I guaranteed that t will only be (attempted to
be) started once?
Thanks,
Ryan
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(thread ing.Thread):
def __init__(self):
self.completed = False
threading.Threa d.__init__(self )
def run(self):
#do something
time.sleep(1)
self.completed = True
t = MyThread()
while t.isAlive() == False and t.completed == False:
t.start()
In the above code, am I guaranteed that t will only be (attempted to
be) started once?
Thanks,
Ryan
Comment