要一直走下去

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

用面向对象来写多线程:

import threading

class MyThread(threading.Thread):
    def __init__(self, n):
        super(MyThread, self).__init__()
        self.n = n
    def run(self):
        print("running task:",self.n)


t1 = MyThread("t1")
t2 = MyThread("t2")
t1.start()
t2.start()

 

posted on 2018-09-16 18:33  要一直走下去  阅读(610)  评论(0编辑  收藏  举报