第1个回答 2017-11-25
#coding=utf-8
import threading
from time import ctime,sleep
res = []
def add(list_num):
print list_num
if __name__ == '__main__':
threads = []
list_num = []
for i in range(1,101):
if len(list_num)==30:
t = threading.Thread(target=add,args=(list_num,))
threads.append(t)
list_num=[]
else:
list_num.append(i)
if list_num:
t = threading.Thread(target=add,args=(list_num,))
threads.append(t)
for t in threads:
t.setDaemon(True)
t.start()本回答被提问者采纳