吴裕雄 python深度学习与实践(2)

#coding = utf8
import threading,time,random count = 0
class MyThread (threading.Thread): def __init__(self,lock,threadName):
super(MyThread,self).__init__(name = threadName)
self.lock = lock def run(self):
global count
self.lock.acquire()
for i in range(100):
count = count + 1
time.sleep(0.3)
print(self.getName() , count)
self.lock.release() lock = threading.Lock()
for i in range(2):
MyThread (lock,"MyThreadName:" + str(i)).start()

吴裕雄 python深度学习与实践(2)

上一篇:mysql数据库常用语句3


下一篇:JAVA算法系列 冒泡排序