Python多线程简单例子
来源:互联网 发布:叉叉助手获取数据失败 编辑:程序博客网 时间:2024/05/22 17:50
直接附上代码:
#!/usr/bin/python# coding:utf-8import threadingimport timeclass Test(threading.Thread): def __init__(self): threading.Thread.__init__(self) # self._run_num = num def run(self): global count, mutex threadname = threading.currentThread().getName() # for x in xrange(0, int(self._run_num)): mutex.acquire() count += 1 mutex.release() print '线程信息名字:', threadname print '在这个线程中的编号: ', x print '累计和: ', count # time.sleep(1)global count, mutexthreads = []num = 4count = 0mutex = threading.Lock()for x in xrange(0, num): threads.append(Test())for t in threads: t.start()for t in threads: t.join()
0 0
- Python 多线程简单例子
- python多线程简单例子
- Python多线程简单例子
- python多线程 简单例子
- python+Tkinter+多线程 简单例子1
- Java 多线程 简单例子
- Qt多线程简单例子
- 多线程简单例子
- 多线程简单例子
- 多线程 -- 初学简单例子
- java多线程简单例子
- QT多线程简单例子
- Python多线程 简明例子
- Python多线程 简明例子
- Python多线程 简明例子
- Python多线程 简明例子
- python 多线程例子
- Python多线程 简明例子
- 2440超详细uboot移植笔记(一)------分析源码
- 191_IO流_BufferedReader_InputStreamReader详解
- 深入理解 I/O 概念
- 剑指offer-面试题38-数字在排序数组中出现的次数
- HTML 5 Canvas vs. SVG 对比
- Python多线程简单例子
- 51nod 四点共面(数学)
- wxWidgets源码分析-事件机制(下)
- Spring MVC视图解析器:Spring MVC ResourceBundleViewResolver示例
- leetcode
- PHP乱码问题
- PHP设计模式系列(十八):命令模式
- URAL
- LCD驱动移植