Nic*_*tes 0 python multithreading
从概念上讲,我想完成以下操作,但却无法理解如何在Python中正确编码:
from threading import Thread
for i in range(0,3):
t = Thread(target=myfunction)
t.start()
# wait until threads have finished executing
print 'complete!'
Run Code Online (Sandbox Code Playgroud)
将线程添加到列表中join().
from threading import Thread
tlist = []
for i in range(3):
t = Thread(target=some_function)
t.start()
tlist.append(t)
# wait until threads have finished executing
for t in tlist:
t.join()
print 'complete!'
Run Code Online (Sandbox Code Playgroud)