在双重检查锁定习语是不是在某些语言可靠,我想知道的Python是否是其中之一。更具体地说,是以下代码...
# Objects shared by threads:
obj = None
lock_for_obj = threading.Lock()
def get_obj():
"""Function called concurrently by threads."""
if obj is None:
with lock_for_obj:
if obj is None:
obj = factory() # Never returns `None`
return obj
... Python中的线程安全?有没有的场景/实现?为什么?