标签:blog thread style ase usr bsp nbsp pytho 线程同步
1 #!/usr/bin/python 2 #coding=utf-8 3 #线程间通信的同步与互斥操作-锁 4 import threading 5 a=b=0 6 lock=threading.Lock() 7 def value(): 8 while 1: 9 lock.acquire() 10 if a!=b: 11 print "a=%d,b=%d"%(a,b) 12 lock.release() 13 t=threading.Thread(target=value) 14 t.start() 15 while True: 16 lock.acquire() 17 a+=1 18 b+=1 19 lock.release()
标签:blog thread style ase usr bsp nbsp pytho 线程同步
原文地址:http://www.cnblogs.com/chengyunshen/p/7195994.html