📜  创建新线程 python 代码示例

📅  最后修改于: 2022-03-11 14:47:19.097000             🧑  作者: Mango

代码示例1
from threading import Thread
from time import sleep

def threaded_function(arg):
    for i in range(arg):
        print("running")
        sleep(1)


if __name__ == "__main__":
    thread = Thread(target = threaded_function, args = (10, ))
    thread.start()
    thread.join()
    print("thread finished...exiting")