我想傳遞值的列表,讓每個人通過了作爲一個獨立的線程列表上:線程的參數
例如:
import time
import threading
list_args = [arg1, arg2, arg3, ...., argn]
# Code to execute in an independent thread
import time
def countdown(n):
while n > 0:
print('T-minus', n)
n -= 1
time.sleep(0.5)
# Create and launch a thread
t1 = threading.Thread(target=countdown, args=(arg1,))
t2 = threading.Thread(target=countdown, args=(arg2,))
.
.
.
tn = threading.Thread(target=countdown, args=(argn,))
t1.start(); t2.start(); tn.start()
謝謝你的意見,因爲我是不確定的調用線程在一個循環中我把它在最近的近似的能力。 –