Create a thread way

class Mythreading(threading.Thread):

    def __init__(self,num):
        threading.Thread.__init__(self)
        self.num = num

    def run(self):
        print("这是线程哦",self.num)
        time.sleep(2)

t1 = Mythreading(1)
t2 = Mythreading(2)

t1.start()
t2.start()

 

Guess you like

Origin www.cnblogs.com/TKOPython/p/12435832.html