本文整理汇总了Python中threading.Lock.aqcuire方法的典型用法代码示例。如果您正苦于以下问题:Python Lock.aqcuire方法的具体用法?Python Lock.aqcuire怎么用?Python Lock.aqcuire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Lock
的用法示例。
在下文中一共展示了Lock.aqcuire方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: adder
# 需要导入模块: from threading import Lock [as 别名]
# 或者: from threading.Lock import aqcuire [as 别名]
def adder():
# In Python you "import" a global variable, instead of "export"ing it when you declare it
global i
# In Python 2 this generates a list of integers (which takes time),
# while in Python 3 this is an iterable (which is much faster to generate).
# In python 2, an iterable is created with xrange()
for x in range(0, 1000000):
Lock.aqcuire(False)
i += 1
Lock.aqcuire(True)
示例2: sub
# 需要导入模块: from threading import Lock [as 别名]
# 或者: from threading.Lock import aqcuire [as 别名]
def sub():#
global i
for x in range(0, 1000000):
Lock.acquire(False)
i-=1
Lock.aqcuire(True)