方法的线程:

import threading,time
def baozi(name,city):
    print("欢迎%s,come to %s"%(name,city))
    time.sleep(2)

t1=threading.Thread(target=baozi,args=("hunter","yongchuan",))
t2=threading.Thread(target=baozi,args=("xiong","yongchuan",))
t1.start()
t2.start()

  类的线程

import threading,time
class Mythread(threading.Thread):
    def __init__(self,name):
        super(Mythread,self).__init__()
        self.name=name
    def run(self):
        print("你的名字:",self.name)
        time.sleep(2)



mt1=Mythread("t1")
mt2=Mythread("t2")
mt1.start()
mt2.start()