摘要: 信号量:允许同一时间几个线程访问公共数据 #!/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... 阅读全文
posted @ 2016-05-27 11:56 zhaogaolong 阅读(1081) 评论(0) 推荐(0) 编辑
摘要: 测试代码: #!/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 =... 阅读全文
posted @ 2016-05-27 11:16 zhaogaolong 阅读(281) 评论(0) 推荐(0) 编辑