上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 15 下一页
摘要: queue is especially useful in threaded programming when information must be exchanged safely between multiple threads. 阅读全文
posted @ 2018-11-18 16:51 rongye 阅读(162) 评论(0) 推荐(0) 编辑
摘要: import timeimport threadingevent = threading.Event()def lighter(): count = 0 event.set() #先设置绿灯 while True: if count >5 and count < 10: #改成红灯 event.cl 阅读全文
posted @ 2018-11-18 16:15 rongye 阅读(168) 评论(0) 推荐(0) 编辑
摘要: import threading, timedef run(n): semaphore.acquire() time.sleep(1) print("run the thread: %s\n" % n) semaphore.release()if __name__ == '__main__': se 阅读全文
posted @ 2018-11-18 15:04 rongye 阅读(189) 评论(0) 推荐(0) 编辑
摘要: import threading, timedef run1(): print("grab the first part data") lock.acquire() global num num += 1 lock.release() return numdef run2(): print("gra 阅读全文
posted @ 2018-11-18 14:59 rongye 阅读(186) 评论(0) 推荐(0) 编辑
摘要: import threadingimport timedef run(n): lock.acquire() global num num +=1 lock.release() time.sleep(1)lock = threading.Lock()num = 0t_objs = [] #存线程实例f 阅读全文
posted @ 2018-11-18 14:19 rongye 阅读(129) 评论(0) 推荐(0) 编辑
摘要: import threadingimport timedef run(n): print("task ",n ) time.sleep(2) print("task done",n)start_time = time.time()t_objs = [] #存线程实例for i in range(50 阅读全文
posted @ 2018-11-18 11:10 rongye 阅读(237) 评论(0) 推荐(0) 编辑
摘要: class BaseRequestHandler: """Base class for request handler classes. This class is instantiated for each request to be handled. The constructor sets t 阅读全文
posted @ 2018-11-17 16:49 rongye 阅读(1230) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/alex3714/articles/5830365.html 阅读全文
posted @ 2018-11-17 15:24 rongye 阅读(109) 评论(0) 推荐(0) 编辑
摘要: import hashlibimport socket ,os,timeserver = socket.socket()server.bind(('0.0.0.0',9999) )server.listen()while True: conn, addr = server.accept() prin 阅读全文
posted @ 2018-11-17 11:42 rongye 阅读(139) 评论(0) 推荐(0) 编辑
摘要: import hashlibm = hashlib.md5()m.update(b"test")m.update(b"abc")print(m.hexdigest())m2 = hashlib.md5()m2.update(b"testabc")print(m2.hexdigest()) 阅读全文
posted @ 2018-11-17 11:10 rongye 阅读(213) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 15 下一页