摘要: 进程与线程的区别 Threads share the address space of the process that created it; processes have their own address space. Threads have direct access to the dat 阅读全文
posted @ 2020-02-24 21:15 w_boy 阅读(317) 评论(0) 推荐(0) 编辑
摘要: 队列作用1、解耦,使程序之间实现松耦合,一个模块修改了不会影响其他的2、提高处理效率 # queue模块中的常用方法: # queue.qsize() 返回队列的大小 # queue.empty() 如果队列为空,返回True,反之False # queue.full() 如果队列满了,返回True 阅读全文
posted @ 2020-02-24 20:13 w_boy 阅读(210) 评论(0) 推荐(0) 编辑
摘要: #线程锁 又叫 互斥锁(Mutex) import threading,time def run(n): lock.acquire() #申请锁 global num num+=1 time.sleep(1) lock.release() #释放锁 lock = threading.Lock() # 阅读全文
posted @ 2020-02-24 16:28 w_boy 阅读(158) 评论(0) 推荐(0) 编辑