You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
653 B

# -*- coding: utf-8 -*-
"""
@Time : 2023/3/29 16:00
@Author :
@FileName:
@Software:
@Describe:
"""
import time
from threading import Thread
c_list = [1,1.1,1.2]
b_list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
d_list = []
def func(a,b):
time.sleep(5)
r = a * b
c_list.append(b)
d_list.append(r)
print(r)
return r
run_list = []
index = 0
start = time.time()
while True:
if c_list == []:
continue
if index == len(b_list):
break
num = c_list.pop()
t = Thread(target=func, args=(num, b_list[index]))
t.start()
index += 1
end = time.time()
print(end-start)
time.sleep(10)
print(d_list)