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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:37:47+00:00 2026-06-16T22:37:47+00:00

For example, I have multi-threaded application which can be presented as: Data bigData; void

  • 0

For example, I have multi-threaded application which can be presented as:

Data bigData;

void thread1()
{
  workOn(bigData);
}
void thread2()
{
  workOn(bigData);
}
void thread3()
{
  workOn(bigData);
}

There are few threads that are working on data. I could leave it as it is, but the problem is that sometimes (very seldom) data are modified by thread4.

void thread4()
{
  sometimesModifyData(bigData);
}

Critical sections could be added there, but it would make no sense to multi-threading, because only one thread could work on data at the same time.

What is the best method to make it sense multi-threading while making it thread safe?

I am thinking about kind of state (sempahore?), that would prevent reading and writing at the same time but would allow parallel reading.

  • 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-06-16T22:37:49+00:00Added an answer on June 16, 2026 at 10:37 pm

    This is called a readers–writer lock. You could implement what is called a mutex to make sure no one reads when write is going on and no one writes when reads are going on. One way to solve the problem would be to have flags. If the writer is got something to modify, then switch on a lock. Upon which NO MORE readers will get to read and after all the current readers have finished, the writer will get to do its job and then again the readers read.

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

Sidebar

Related Questions

i have a multi-threaded application which wants to send a sequence of data to
I have a multi-threaded application that is using pthreads. I have a mutex() lock
I have a multi-threaded gSOAP service running with enabled http-keepalive. How can I gracefully
I have a c# multi-threaded monte carlo simulation , the application is already structured
we have a multi-threaded desktop application in C++ (MFC). Currently developers use either CString
I have a multi threaded wpf application with various HW interfaces. I want to
Recently I have started work on a multi-threaded console based application using VB.Net and
I have a simple multi-threaded program, with the following structure. public void someFunction() {
I am trying to create a multi threaded PHP application right now. I have
I have an application which is CPU intensive. When the data is processed on

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.