Loading

Python 多线程

 

 

import threading
import time

def userTest(aa,bb):
    print(aa)
    time.sleep(3)
    print(bb)


if __name__ == '__main__':
    threads = []
    # target=执行的函数,args=传给函数的值,range代表打开几个线程执行
    for _ in range(33):
        t = threading.Thread(target=userTest,args=("开始","结束"))
        threads.append(t)

    # 打开线程活动
    for thr in threads:
        thr.start()

    # 等待至线程中止
    for thr in threads:
        thr.join()

 

posted @ 2020-11-05 21:19  Outsrkem  阅读(91)  评论(0编辑  收藏  举报