Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you misundertood this whole thread safety thing. It's not so much about variables (or variable variables - those are terrible anyway, and are just as pointless - not to say harmful - here as in every other case) but about -- for example, there are many nasty nasty ways threading can go wrong; they all come from accessing something mutable from more than one thread at overlapping times -- this:</p> <ul> <li>thread N gets data from source (some place in memory or on disk - a variable, a slot in a dictionary, a file, pretty much anything mutable)</li> <li>thread M gets data from source</li> <li>thread N modifies the data</li> <li>thread M modifies the data</li> <li>thread N overwrites source with modified data</li> <li>thread M overwrites source with modified data</li> <li>Result: thread N's modifications are lost/the new shared value doesn't take thread N's modifications into account</li> </ul> <p>And it applies to dictionaries and variable variables (which are just a horrible, horrible language-level implementation of dicts with string-only keys) as well. The only solutions are not using shared state to begin with (functional languages do this by discouraging or even completely disallowing mutability, and it works well for them) or adding some sort of locking to everything shared (hard to get right, but if you get it right, at least it works correctly). If no two threads every share anything in that dictionary, you're fine - but you should seperate everything, to be (a bit more) sure that they really don't share anything.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload