python线程教程,如何进行建立Python主线程

1,如何进行建立Python主线程使用线程安全的queue来中转数据就好了【python线程教程,如何进行建立Python主线程】
2 , python里怎么创建线程threadingthreading.Thread
3,python中如何创建并开启一个线程使用线程池:threadpool 模块 。这是一个第三方模块 , 可以通过下面方法安装:easy_install threadpoola=[]a.add("1")a.add("hi")print a##结果: ["1","hi"]
4 , python中如何对类的成员函数开启线程# -*- coding: utf-8 -*-import threadingimport threadimport timeclass Test(object): def __init__(self): # threading.Thread.__init__(self) self._sName = "machao" def process(self): #args是关键字参数,需要加上名字,写成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()看注释 。如果解决了您的问题请采纳!如果未解决请继续追问程序如下:import threadingimport threadimport timeclass Test(object):def __init__(self):#threading.Thread.__init__(self)self._sName = "machao"def process(self):th1 = threading.Thread(target = Test.buildList , (self ,))th1.start()th1.join()def buildList(self):while True:print "start"time.sleep(3)test = Test()test.process()# -*- coding: utf-8 -*-import threadingimport threadimport timeclass test(object):def __init__(self):# threading.thread.__init__(self)self._sname = "machao"def process(self):#args是关键字参数,需要加上名字,写成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()

    推荐阅读