摘要:
信号量:允许同一时间几个线程访问公共数据 #!/usr/bin/python # coding:utf8 import threading import time p_list = [] num = 0 def run(n): semaphore.acquire() time.sleep(1) print 'this is %s num' % n semaph... 阅读全文
摘要:
测试代码: #!/usr/bin/python # coding:utf8 import threading import time num = 0 def run(n): print 'this is %s num' % n global num time.sleep(1) num += 1 for i in range(200): t =... 阅读全文