本文實(shí)例講述了Python自定義線程類。分享給大家供大家參考,具體如下:
一. 代碼
# -*- coding:utf-8 -*-#! python2import threadingclass mythread(threading.Thread): def __init__(self, num): threading.Thread.__init__(self) self.num = num def run(self): print('I am {0}'.format(self.num))t1 = mythread(1)t2 = mythread(2)t3 = mythread(3)t1.start()t2.start()t3.start()二. 運(yùn)行結(jié)果

希望本文所述對大家Python程序設(shè)計有所幫助。
|
新聞熱點(diǎn)
疑難解答
圖片精選