How do I know when all threads are done?
Christian Heimes
lists at cheimes.de
Thu May 22 07:58:27 EDT 2008
Zerge schrieb:
> I can launch threads just fine, but then I have to do a time.sleep(n)
> so the main thread from which they where launched will wait for all
> the threads to return.
>
> How can I detect when all threads are done and then return control to
> the main threads?
import threading
threads = []
threads.append(threading.Thread(...))
threads.append(threading.Thread(...))
threads.append(threading.Thread(...))
for thread in threads:
thread.start()
# now all threads are running, some might already be done
for thread in threads:
thread.join()
# here all threads are done
Christian
More information about the Python-list
mailing list