import threading,time
from tools.listOperation import *


class MyThread(threading.Thread):
    def __init__(self,func,divlist):
        super(MyThread,self).__init__()
        self.func=func
        self.divlist=divlist
    def run(self):
        #time.sleep(1)
        #print(threading.currentThread().name)
        self.func(self.divlist)
        #print('over')

def func(divlist):
    for i in divlist:
        print(i)

def main(thnum):
    num=list(range(100))
    #thnum=5
    divnum=int(len(num)/thnum)
    divlists=split_by_length(num,divnum)
    #print(divlists)
    temp=[]
    for i in range(thnum):
        t=MyThread(func,divlists[i])
        temp.append(t)
        t.start()
    for i in temp:
        i.join()


if __name__ == '__main__':
     t=time.time()
     main(5)
     tt=time.time()
     print(tt-t)
     # print("=="*50)
     # t=time.time()
     # for i in list(range(100)):
     #     print(i)
     # tt=time.time()
     # print(tt-t)







