__author__ = "JentZhang"

 import time, threading, queue

 q = queue.Queue(maxsize=)  # 声明队列

 def Producer(name):
'''生产者'''
count =
while True:
q.put(count) # 往队列中添加数据
print("[%s] 生产了第%s包子\n" % (name, count))
count +=
time.sleep() def Consumer(name):
'''消费者'''
while True:
i = q.get() # 从队列中取数据
print("====[%s] 吃了第%s个包子\n" % (name, i))
time.sleep() '''设置多线程'''
p = threading.Thread(target=Producer, args=("Jent",))
c1 = threading.Thread(target=Consumer, args=("张三",))
c2 = threading.Thread(target=Consumer, args=("李四",)) '''线程开启'''
p.start()
c1.start()
c2.start()

最新文章

  1. 修改 Docker 默认网桥地址
  2. OAF_开发系列17_实现OAF数组应用Vector / Hashmap / Hashtable / Arraylist(案例)
  3. xUtils,butterknife...处理findviewbyid
  4. Java多态与C++中多态的实现
  5. light oj 1393 - Crazy Calendar 博弈论
  6. linux自己带的apache重新启动
  7. multipath.conf
  8. Xcode开启gcc/g++
  9. struts 学习之问一
  10. sqlprofiler 常用调试方法
  11. Top 10 Mapping APIs: Google Maps, Microsoft Bing Maps and MapQuest
  12. C语言之一数三平方
  13. Android学习笔记:adb 与 adb shell操作 以及中文乱码解决
  14. 关于阮大神的es6标准入门第一章
  15. 洛谷 P1129 解题报告
  16. margin-塌陷问题
  17. Gatsby上手指南 - 让你的静态网站用react来高逼格的写
  18. 轻量级ORM框架 Bankinate
  19. 09-babel
  20. SpringBoot的第一个web项目

热门文章

  1. Teradata Delete Database and Drop Database
  2. Hadoop-2.0 目录简介
  3. Linux 搜某个文件里关键字的上下500行到执行文件里
  4. Ubuntu 16——安装——ns2.35和nam
  5. asp.net执行顺速
  6. 安装PyQt5时缺少designer.exe的解决办法
  7. cf Round#273 Div.2
  8. python爬虫学习之爬取全国各省市县级城市邮政编码
  9. IM系统的MQ消息中间件选型:Kafka还是RabbitMQ?
  10. Javascript高级编程学习笔记(25)—— 函数表达式(3)模仿块级作用域