多线程相关

import time
from threading import Thread
def func(n):
    #time.sleep(1)
    print(n)
for i in range(10):
    t = Thread(target=func,args=(i,))
    t.start()

import time
from threading import Thread
class MyThread(Thread):
    def __init__(self,args):
        super().__init__()
        self.args = args
    def run(self):
        time.sleep(1)
        print(self.args)
for i in range(10):
    t = MyThread(i)
    t.start()

posted @ 2018-12-16 13:51  superniao  阅读(85)  评论(0编辑  收藏  举报