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

  • Home
  • SEARCH
  • 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 770959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:34:50+00:00 2026-05-14T18:34:50+00:00

I have an application that will be spawning multiple threads. However, I feel there

  • 0

I have an application that will be spawning multiple threads. However, I feel there might be an issue with threads accessing data that they shouldn’t be.

Here is the structure of the threaded application (sorry for the crudeness):

                   MainThread
                  /          \
                 /            \
                /              \
        Thread A               Thread B
       /        \              /       \
      /          \            /         \
     /            \          /           \
Thread A_1     Thread A_2   Thread B_1    Thread B_2

Under each lettered thread (which could be many), there will only be two threads and they are fired of sequentially. The issue i’m having is I’m not entirely sure how to pass in a datastructure into these threads.

So, the datastructure is created in MainThread, will be modified in the lettered thread (Thread A, etc) specific to that thread and then a member variable from that datastructure is sent to Letter_Numbered threads.

Currently, the lettered thread class has a member variable and when the class is constructed, the datastructure from mainthread is passed in by reference, invoking the copy constructor so the lettered thread has it’s own copy to play with.

The lettered_numbered thread simply takes in a string variable from the data structure within the lettered thread. My question is, is this accceptable? Is there a much better way to ensure each lettered thread gets its own data structure to play with?

Sorry for the somewhat poor explanation, please leave comments and i’ll try to clarify.

EDIT:
So my lettered thread constructor should take the VALUE of the data structure, not the reference?

  • 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-14T18:34:51+00:00Added an answer on May 14, 2026 at 6:34 pm

    I would have each thread create it’s own copy of the datastructure, e.g. you pass the structure in the constructor and then explicitly create a local copy. Then you are guaranteed that the threads have distinct copies. (You say that it’s passsed by reference, and that this invokes the copy constructor. I think you mean pass by value? I feel it’s better to explicitly make a copy, to leave no doubt and to make your intent clear. Otherwise someone might later come along and change your pass by value to pass by reference as a “smart optimization”.)

    EDIT: Removed comment about strings. For some reason, I was assuming .NET.

    To ensure strings are privately owned, follow the same procedure, create a copy of the string, which you can then freely modify.

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

Sidebar

Ask A Question

Stats

  • Questions 511k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer FieldStorage is useful in CGI contexts and can help in… May 16, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer Tested on recent setup (Apache httpd 2.2.16, Tomcat 6.0.29, mod_jk… May 16, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer Try Image img = System.Drawing.Image.FromStream(myStream); img.Save(System.IO.Path.GetTempPath() + "\\myImage.Jpeg", ImageFormat.Jpeg); May 16, 2026 at 5:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an application that will support multiple sites. The site will be determined
i have a application that will have multiple uiviewcontrollers, the navigation in the application
I have an application that will upload files from my client to a web
We have a .NET application that needs to pass some data over to a
I'm trying to build a basic application which will have 2 separate components which
I have a ColdFusion application that's behind an ISA Server. Part of the application
I have a Silverlight application that I am maintaining. I am currently using Visual
I have this GUI that shows, let's say Customer Orders. When my client nailed
I'm creating a data-entry application where users are allowed to create the entry schema.
We have an implementation for an Ultrasound machine application current where the Ultrasound object

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.