python多线程调用规范

dsysama

关注

阅读 91

2023-03-16


import threading
import time
import random


# threading.Thread(target=None, args=())
def hello():
time.sleep(random.random())
print("hello world %d" % threading.active_count())
arr = []
def wait():
for x in arr:
x.join()
print("所有程序执行完毕")
# hello()

for x in range(10):
t = threading.Thread(target=hello)
t.start()
arr.append(t)


threading.Thread(target=wait).start()
print("没有阻塞")
# 没有阻塞

精彩评论(0)

0 0 举报