<div dir="ltr">Hi,<div>if I have a class A that contains a boolean variable named x, is it safe to read and change it from different threads without using locks?</div><div>Is it guaranteed that A.x will be always True or False, and not any other weird value that that causes it to be inconsistent (assuming I only set it to True or False) ?</div>
<div><br></div><div>I have a = A()</div><div>first thread does:</div><div>if a.x is True :</div><div> pass</div><div><br></div><div>2nd thread does:</div><div>a.x = False</div><div><br></div><div>is it safe?</div><div>
<br></div><div>and what if x was a dict ? especially if the only values that are set in the dictionary are simple: booleans, integers, floats, strings</div></div>