我希望Python中的3个Threads运行n
秒。我想同时启动它们并让它们同时完成(在几毫秒内)。我该怎么做?
threading.Timer
仅在前一个完成后开始。
答案 0 :(得分:4)
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()
打印:
here 1279553593.49
here 1279553593.49
here 1279553593.49
there 1279553603.5
there 1279553603.5
there 1279553603.5