參考 https://www.cnblogs.com/yeayee/p/4952022.htmlhtml
但這文章裏有 那個t.join() 在外面, 就能執行完 ,應該是錯的 最多就一個線程玩感受python
import threading def test_thread(): print("start threads") threads = [] for stock_name in stock_name_list: print(stock_name) th = threading.Thread(target=callbackfunc,args=(param0,param1)) threads.append(th) for t in threads: t.setDaemon(True) # 設置爲守護進程,否則線程會被掛起 t.start() for t in threads: t.join() print("threads over")
callbackfunc 就要執行的函數 param0,param1 是 callbackfunc的參數app