python进程与线程混合使用例子
来源:互联网 发布:开源搜索引擎源码 编辑:程序博客网 时间:2024/06/07 06:12
from gevent import monkey; monkey.patch_all()
import gevent
import multiprocessing
import threading
import time
def thread_handle():
print ("\033[1;33;42m now,begin handle thread task.......\033[0m")
time.sleep(2)
print("\033[1;31;42m now,end handle thread task.......\033[0m")
def process_handle():
print ("now,begin handle process task.........")
t_list = []
for i in range(5):
t = threading.Thread(target=thread_handle,)
t.start()
t_list.append(t)
for i in t_list:
i.join()
if __name__ == '__main__':
p_list = []
for i in range(10):
p = multiprocessing.Process(target=process_handle,)
p.start()
p_list.append(p)
for i in p_list:
i.join()
print ("now,every process task handle complete.........")
import gevent
import multiprocessing
import threading
import time
def thread_handle():
print ("\033[1;33;42m now,begin handle thread task.......\033[0m")
time.sleep(2)
print("\033[1;31;42m now,end handle thread task.......\033[0m")
def process_handle():
print ("now,begin handle process task.........")
t_list = []
for i in range(5):
t = threading.Thread(target=thread_handle,)
t.start()
t_list.append(t)
for i in t_list:
i.join()
if __name__ == '__main__':
p_list = []
for i in range(10):
p = multiprocessing.Process(target=process_handle,)
p.start()
p_list.append(p)
for i in p_list:
i.join()
print ("now,every process task handle complete.........")
阅读全文
0 0
- python进程与线程混合使用例子
- Python 进程与线程
- python 线程与进程
- python 线程与进程
- Python进阶 - 进程与线程
- Python 之 线程与进程
- Python中线程与进程
- Python的进程与线程
- python从线程结束主进程的例子
- 进程线程例子
- Python的进程与线程问题
- python线程、进程与协程
- python -- 进程与线程 (一)
- 操作 python -- 进程与线程 (二)
- python ----进程与线程(三)
- python(十)线程与进程(中):进程、协程
- python与C混合
- 系统进程与线程关系以及使用Python获取的方法
- 利用LoRa跨入物联网通讯技术
- AHCI,SATA,NVME
- 第二周项目一c/c++语言中函数参数传递的三种方式
- 机器学习-特征选择
- git submodule的使用
- python进程与线程混合使用例子
- 小白的踩坑记录——SOCKET.IO—API
- HibernateTemplate常用的方法
- kylin drbd 安装配置
- 低功耗传输与智能硬件技术成熟 为物联网应用构建基础
- 高效程序员的狂暴之路
- Swift 图片添加文字水印
- 动画相关
- 【PDF下载】金融技术峰会之支付宝APP无线网络性能保障