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 4244476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:42:47+00:00 2026-05-21T03:42:47+00:00

I currently program a program which uses multiple threads. To be able to share

  • 0

I currently program a program which uses multiple threads. To be able to share data across these threads I use Locks like threading.Lock to avoid access problem during run.

But the problem that I got is that I have to create huge amount locks for every data just for reading that data. Even if I ‘group’ data and use for them the same lock there are too many of them.

So I am asking myself: If a thread just reads data and does not changes it (that also applies to all other threads), are there any problems which can occur?

Thanks in advance,

  • 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-21T03:42:47+00:00Added an answer on May 21, 2026 at 3:42 am

    If all your threads just read data, there is no problem accessing the data simultaneously from different threads, as long as reading the data does not change it. Changing the read data can occur in some data structure, defaultdict being a tricky example.

    If you have a consumer\producer scenario, consider using Queue.Queue, a thread-safe data structure which allows simultaneous reads and writes. From the Python documentation:

    def worker():
        while True:
            item = q.get()
            do_work(item)
            q.task_done()
    
    q = Queue()
    for i in range(num_worker_threads):
         t = Thread(target=worker)
         t.daemon = True
         t.start()
    
    for item in source():
        q.put(item)
    
    q.join()       # block until all tasks are done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a small Java program which I would like to run both
I have a (C#) genetic program that uses financial time-series data and it's currently
Currently, while compiling a C program which uses pthread library function I have to
I've got a program which is working and uses Core Data for storage. However,
How can I check the umask of a program which is currently running? [update:
Program design: Class A, which implements lower level data handling Classes B-E, which provide
I'm currently working on a program where there are multiple icons dynamically added to
Preliminary story There is this program which uses the Parallel Port to synchronize with
I'm currently using FreeImage to load PFMs into a program that otherwise uses IplImages
I'm currently designing a program that will involve some physics (nothing too fancy, a

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.