码迷,mamicode.com
首页 > 编程语言 > 详细

Python简单的多线程demo:装逼写法

时间:2018-09-16 19:46:45      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:self   import   threading   class   __init__   running   code   简单的   线程   

用面向对象来写多线程:

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()

 

Python简单的多线程demo:装逼写法

标签:self   import   threading   class   __init__   running   code   简单的   线程   

原文地址:https://www.cnblogs.com/staff/p/9656913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!