您的位置:首页 > 编程语言 > Python开发

Python线程类首先是一个类

2015-12-04 23:22 363 查看
直接用代码说话,有关基本概念可查阅操作系统有关书籍和《Python程序设计》(董付国编著,清华大学出版社,2015.8第一版)。

import threading

class myThread(threading.Thread):

def __init__(self, threadName):

threading.Thread.__init__(self)

self.name = threadName

def run(self):

print('In run:', self.name)

def output(self):

print('In output:', self.name)

t = myThread('test')

t.output()

t.start()

运行结果如图所示:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: