码迷,mamicode.com
首页 > 其他好文 > 详细

threading start() 和 run() 的区别

时间:2019-02-24 00:30:02      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:running   super   self   mat   int   work   import   while   orm   

threading Tread run() 和 start()区别
import threading
import time

def worker():
    count = 0
    while True:
        if count > 5:
            break
        time.sleep(1)
        count += 1
        print(‘worker running and threading_name={}‘.format(
            threading.current_thread().name))

class MyThread(threading.Thread):
    def start(self):
        print(‘start-------‘)
        super().start()

    def run(self):
        print(‘run------‘)
        super().run()

t = MyThread(name=‘worker‘,target=worker)
# t.start()
t.run()

threading start() 和 run() 的区别

标签:running   super   self   mat   int   work   import   while   orm   

原文地址:https://blog.51cto.com/windchasereric/2353993

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