摘要:
#!/usr/bin/env python# -*- coding: utf-8 -*-from threading import Threadfrom Queue import Queueimport timeclass Producer(Thread): def __init__(self,na 阅读全文
摘要:
#!/usr/bin/env python# -*- coding: utf-8 -*-import threadingimport timedef customer(cond): t = threading.currentThread() with cond: # wait()方法创建了一个名为w 阅读全文
摘要:
#!/usr/bin/env python# -*- coding: utf-8 -*-import threadingimport timevalue = 0lock = threading.Lock()def add(): global value with lock: new_value = 阅读全文
摘要:
输出: python t_Semaphore.py 0 acquire sema1 acquire sema2 acquire sema 1 releas sema2 releas sema0 releas sema3 acquire sema4 acquire sema4 releas sema 阅读全文