摘要:
```
from threading import Thread,current_thread
from queue import Queue
import time class ThreadPool: def __init__(self,n): self.queue=Queue() for i in range(n):#在线程池里面开启n个线程 ... 阅读全文
posted @ 2018-01-23 17:53
nanaindi
阅读(124)
评论(0)
推荐(0)
摘要:
```
#python自带的线程池
from multiprocessing.pool import ThreadPool #注意ThreadPool不在threading模块下
from multiprocessing import Pool #导入进程池 def func(*args,**kwargs): print(args,kwargs) pool=ThreadPool(2)
... 阅读全文
posted @ 2018-01-23 17:52
nanaindi
阅读(2363)
评论(0)
推荐(0)
摘要:
```
#使用池来实现并发服务器
import socket
from multiprocessing import cpu_count,Pool
from multiprocessing.pool import ThreadPool server=socket.socket()
server.bind(('0.0.0.0',8080))
server.listen(1000) def wo... 阅读全文
posted @ 2018-01-23 17:50
nanaindi
阅读(151)
评论(0)
推荐(0)

浙公网安备 33010602011771号