Python 多线程
来源:互联网 发布:编程实现快速排序算法 编辑:程序博客网 时间:2024/06/08 05:10
import sysimport osimport timeimport threadingimport Queueimport multiprocessingdef ProcessFunction(job): print jobclass WorkerThread(threading.Thread): def __init__(self, jobQueue): threading.Thread.__init__(self) self.daemon = True self.__jobQueue = jobQueue def run(self): while True: if self.__jobQueue.empty(): break ProcessFunction(self.__jobQueue.get()) self.__jobQueue.task_done() print "Remaining tasks: ", self.__jobQueue.qsize()def RunWithMultithreading(inputJobs): jobQueue = Queue.Queue() for job in inputJobs: jobQueue.put(job) for x in range(multiprocessing.cpu_count()): WorkerThread(jobQueue).start() jobQueue.join()if __name__ == '__main__': RunWithMultithreading(["job1", "job2", "job3"])
0 0
- Python多线程
- Python多线程
- Python多线程
- python多线程
- python 多线程
- python多线程
- python多线程
- python 多线程
- python多线程
- Python多线程
- Python 多线程
- python多线程
- python 多线程
- {python多线程}
- Python 多线程
- Python多线程
- python 多线程
- Python 多线程
- skiing 问题
- Java对象的生命周期
- 攻壳机动队 Ghost in the Shell
- 第8节 理解进程调度时机跟踪分析进程调度与进程切换的过程【Linux内核分析】
- Java反射调用静态方法
- Python 多线程
- 题目1087:约数的个数
- 速度与激情8 The Fate of the Furious
- c指针*和++
- C#操作PDF总结
- Genymotion模拟器在Android Studio中检查不到
- 24:鸣人的影分身
- 流
- 最长公共字符串