How do I know when a thread quits?
dowskimania at gmail.com
dowskimania at gmail.com
Tue Jun 7 12:18:01 EDT 2005
I'm no threads expert, but if you use the higher-level "threading"
module, you could try something like this:
import threading
import time
def countToTen():
for i in range(1,11):
print i
time.sleep(0.5)
child = threading.Thread(target=countToTen)
class masterThread(threading.Thread):
def run(self):
print "Master Started"
child.start()
while child.isAlive():
time.sleep(0.1)
print "Master Finished"
master = masterThread()
master.start()
---------------SCRIPT OUTPUT--------------
Master Started
1
2
3
4
5
6
7
8
9
10
Master Finished
Hope this helps.
Christian
http://www.dowski.com
More information about the Python-list
mailing list