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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:47:49+00:00 2026-05-17T19:47:49+00:00

Take a boolean value. One thread is trying to assign a pre-determined value to

  • 0

Take a boolean value. One thread is trying to assign a pre-determined value to it, and at exactly the same time another thread is trying to read it. What happens?

  • 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-17T19:47:50+00:00Added an answer on May 17, 2026 at 7:47 pm

    Take a boolean value. One thread is trying to assign a pre-determined value to it, and at exactly the same time another thread is trying to read it. What happens?

    This depends on the architecture and language in question. In practice, this typically means you’ll have a race condition, and the “read” value may be the old or new value.

    It’s more interesting if two threads to try write to the same variable at the same time – if one writes false and the other true, the actual resulting variable may end up with either value.

    In order to guarantee proper access, a memory barrier needs to be in place. This is especially true if dealing with multiple processors or even multiple cores, as the CPU cache lines need to be invalidated after a thread writes in order for a separate thread to read a value. Most languages have support for this in one form or another – for example, in C#, you can flag a variable as volatile in order to assist in this, but explicit synchronization (ie: locking) is typically still required.

    Also, if the variable write is not a single CPU instruction (ie: using an interlocked operation or similar), care must be taken to explicitly synchronize the access for read and write – otherwise, you can (on some architectures) get the variable in a third, indeterminate state.

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

Sidebar

Related Questions

No related questions found

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.