摘要: #!/usr/bin/env python# -*- coding: utf-8 -*-from threading import Threadfrom Queue import Queueimport timeclass Producer(Thread): def __init__(self,na 阅读全文
posted @ 2017-09-24 15:14 泽锦 阅读(470) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# -*- coding: utf-8 -*-import threadingimport timedef customer(cond): t = threading.currentThread() with cond: # wait()方法创建了一个名为w 阅读全文
posted @ 2017-09-24 11:23 泽锦 阅读(638) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# -*- coding: utf-8 -*-import threadingimport timevalue = 0lock = threading.Lock()def add(): global value with lock: new_value = 阅读全文
posted @ 2017-09-24 10:59 泽锦 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 输出: python t_Semaphore.py 0 acquire sema1 acquire sema2 acquire sema 1 releas sema2 releas sema0 releas sema3 acquire sema4 acquire sema4 releas sema  阅读全文
posted @ 2017-09-24 10:40 泽锦 阅读(738) 评论(0) 推荐(0) 编辑