摘要: # __author: "ZXYang"# #date: 2020/5/18from multiprocessing import Processimport timeclass MyProcess(Process): def __init__(self, name): super(MyProces 阅读全文
posted @ 2020-12-20 22:39 zxy_ang 阅读(62) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/5/18from multiprocessing import Processimport timedef pr(name): print('process', time.ctime())if __name__ == '__main_ 阅读全文
posted @ 2020-12-20 22:38 zxy_ang 阅读(43) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/12/20"""队列:优先级队列:PriorityQueue"""import queuequ = queue.PriorityQueue()qu.put((1, '11'))qu.put((2, '22'))qu.put((-2, 阅读全文
posted @ 2020-12-20 22:19 zxy_ang 阅读(124) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/12/20"""队列:后入先出:LifoQueue"""import queuequ = queue.LifoQueue()qu.put(11)qu.put(22)qu.put(33)qu.put(44)qu.put(55)print 阅读全文
posted @ 2020-12-20 22:18 zxy_ang 阅读(226) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/12/20"""列出100个url地址(假设请求每个地址需要0.5秒)请设计程序,一个程序,访问地址列表中的url,使用四个线程发送这100个请求,计算总时间!"""import timeimport queuefrom thread 阅读全文
posted @ 2020-12-20 21:26 zxy_ang 阅读(94) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/5/16"""队列:先入先出:queue消息 == 任务"""import queuequ = queue.Queue(3)qu.put('a1')qu.put('a2')qu.put('a3')# qu.put('a4') # 添加 阅读全文
posted @ 2020-12-20 19:42 zxy_ang 阅读(76) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/5/13import threadingclass MyThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) # self.num 阅读全文
posted @ 2020-12-20 17:28 zxy_ang 阅读(70) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/5/12import threadingimport time# from time import timedef addnum(): global num lock.acquire() # 加锁,计算完后,进行下个线程,比t.joi 阅读全文
posted @ 2020-12-20 17:27 zxy_ang 阅读(132) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/5/11# import threading# import time### class MyThread(threading.Thread):## def __init__(self, num):# threading.Thread 阅读全文
posted @ 2020-12-20 16:25 zxy_ang 阅读(73) 评论(0) 推荐(0)
摘要: # __author: "ZXYang"# date: 2020/5/11import threadingimport timedef mu(func): # print(threading.current_thread()) for i in range(2): print('Begin1 %s. 阅读全文
posted @ 2020-12-20 16:23 zxy_ang 阅读(66) 评论(0) 推荐(0)