I would like 3 Threads in Python to run for n
seconds. I want to start them all at the same time and have them f开发者_运维知识库inish at the same time (within milliseconds). How do I do this?
threading.Timer
only starts after the previous one has been completed.
import threading
import time
class A(threading.Thread):
def run(self):
print "here", time.time()
time.sleep(10)
print "there", time.time()
if __name__=="__main__":
for i in range(3):
a = A()
a.start()
prints:
here 1279553593.49
here 1279553593.49
here 1279553593.49
there 1279553603.5
there 1279553603.5
there 1279553603.5
精彩评论