python(threading 线程模块 继承式调用)

# Author:Sooele

import threading   #线程模块
import time

class MyThread(threading.Thread):
    def __init__(self,n):
        super(MyThread,self).__init__() #super 继承
        self.n = n

    def run(self):
        print("runnint task",self.n)


t1 = MyThread("t1")
t2 = MyThread("t2")

t1.start()
t2.start()

发表评论