欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python 對類的成員函數(shù)開啟線程的方法

 更新時間:2019年01月22日 14:36:34   作者:zhongfuyu  
今天小編就為大家分享一篇python 對類的成員函數(shù)開啟線程的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

如下所示:

# -*- coding: utf-8 -*-
import threading
import thread
import time


class Test(object):
  def __init__(self):
    # threading.Thread.__init__(self)
    self._sName = "machao"

  def process(self):
    #args是關(guān)鍵字參數(shù),需要加上名字,寫成args=(self,)
    th1 = threading.Thread(target=Test.buildList, args=(self,))
    th1.start()
    th1.join()

  def buildList(self):
    while True:
      print "start"
      time.sleep(3)


test = Test()
test.process()

以上這篇python 對類的成員函數(shù)開啟線程的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論