python 多线程2-线程的创建启动,退出

# encoding: UTF-8
import threading
import time

class MyThread(threading.Thread):
    def run(self):
        for i in range(3):
            time.sleep(1)
            msg = "I'm "+self.name+' @ '+str(i)
            print msg
def test():
    for i in range(5):
        t = MyThread()
        t.start()
if __name__ == '__main__':
    test()

  

posted @ 2016-03-28 14:48  gopher-lin  阅读(304)  评论(0编辑  收藏  举报