pythonmultithreadingequivalent

Python equivalent of Java synchronized


In Java, you can make a variable thread safe by just adding the synchronized keyword. Is there anything that can achieve the same results in Python?


Solution

  • You can use with self.lock: and then put your code inside there. See http://theorangeduck.com/page/synchronized-python for more information.