Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3611470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:52:48+00:00 2026-05-18T21:52:48+00:00

When it comes to threading, I know you have to make sure you’re not

  • 0

When it comes to threading, I know you have to make sure you’re not editing a variable at the same time another thread is editing it, as your changes can be lost (when incrementing a counter, for example)

Does the same apply to dictionaries? Or is a dictionary a collection of variables?

If every thread were to lock the dictionary it would slow the program down significantly, while every thread only needs write access to its own little piece of the dictionary.

If it isn’t possible, is there some sort of variable variable in python, like in php?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:52:48+00:00Added an answer on May 18, 2026 at 9:52 pm

    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:

    • 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)
    • thread M gets data from source
    • thread N modifies the data
    • thread M modifies the data
    • thread N overwrites source with modified data
    • thread M overwrites source with modified data
    • Result: thread N’s modifications are lost/the new shared value doesn’t take thread N’s modifications into account

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a noob when it comes to threading in C#, and I'm not sure
It comes up from time to time and I'm wondering of it's possible to
I've been studying .Net threading and have learned about the Threading.Task and Threading.Task.Parallel classes.
I'm a multiprocessing newbie, I know something about threading but I need to increase
not sure if this question should be here or in serverfault, but it's java-related
In my WPF Window_Loaded event handler I have something like this: System.Threading.Tasks.Task.Factory.StartNew(() => {
I should start by saying that I know no VBA I have to enter
I have read a lot of material on threading, and all the synchronization mechanisms
Rails comes with a handy session hash into which we can cram stuff to
Django comes with CSRF protection middleware , which generates a unique per-session token for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.