python多线程,限制线程数
2013-11-09 19:08
513 查看
#encoding:utf8 import threading import time data = 0 def func(sleeptime): global data print threading.currentThread().getName() time.sleep(sleeptime) threads = [] for i in range(0,40): t = threading.Thread(target=func,args=(i,)) threads.append(t) num = 0 for t in threads: t.start() while True: #判断正在运行的线程数量,如果小于5则退出while循环, #进入for循环启动新的进程.否则就一直在while循环进入死循环 if(len(threading.enumerate()) < 5): break
相关文章推荐
- python多线程,限制线程数
- python多线程,限制线程数
- python多线程之限制同时运行的线程个数
- 【Java多线程】使用Semaphore限制资源访问的线程数
- python多线程异步post请求脚本,可以设置持续运行时间、线程数、时间间隔
- Python实现可设置持续运行时间、线程数及时间间隔的多线程异步post请求功能
- python多线程异步post请求脚本,可以设置持续运行时间、线程数、时间间隔
- python多线程限制并发数示例
- Python继承类的方式实现多线程及控制线程数
- 关于"Google限制Python"事件我的看法
- (Python)scapy——多线程发送icmp数据包
- 基于OkHttp Retrofit RxJava 多线程下载。请求、缓存、自动更新.限制队列数.封装库
- Python 多线程教程:并发与并行
- Python 多进程_进程池_多线程_线程池实现比较
- Python多线程
- 服务端socket开发之多线程和gevent框架并发测试[python语言] 推荐
- python 如何设置多线程
- python多线程之semaphore(信号量)
- 多线程编程---python
- LINUX如何限制单个用户的线程数