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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:55:45+00:00 2026-05-23T07:55:45+00:00

This would be done without mutexes. I just want to know if it is

  • 0

This would be done without mutexes. I just want to know if it is thread safe ie the program will not crash or something similar. I do not really care that the variable could be in the wrong state when it is read as the consequence is not fatal (only impact would be making a copy of a small data structure when not necessary)
I am using Qt.

Here is the context that could happen: from the main thread, I would be setting a bool that is a member of a qthread. While or after I am setting the bool to true, the qthread could be in the function that uses this bool (this is a function that is used by the main thread and the qthread, everything is already protected and synchronised so as to not have the function being run by both threads simultaneously)

Kinda think of it, since this bool is only used by the main thread anyways I will check which thread is in the function and that should solve that but I am still curious.

  • 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-23T07:55:45+00:00Added an answer on May 23, 2026 at 7:55 am

    You seem to be asking about what are called benign races.

    For example consider an integer variable representing a progress value in the range 0 to 100. You read it from one thread at the same time as you are incrementing from another. You don’t mind whether you read the value before the write or the value after the write. You’ll read it again soon and then you’ll get the value from after the write.
    In that scenario the race is benign. However what may not be benign is something called tearing. The hardware may allow you to read the value whilst only some part of the memory has been written to by the other thread.

    For example the writing thread may write the low word, then the read of both words occurs and then the high word is written. Tearing can lead to incorrectness.

    The hardware does provide guarantees about tearing but they vary between architectures. For example x86 has atomic access, i.e. no tearing, for 4 byte wide data that is 4 byte aligned.

    If you are writing portable code then you are in quite tricky waters because the current standard gives no guarantees about atomicity. If you can make assumptions on your hardware platform then you may be able to take advantage of benign races.

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

Sidebar

Related Questions

I thought this would have done it... $rowfetch = $DBS->{Row}->GetCharValue(meetdays); $rowfetch = /[-]/gi; printline($rowfetch);
I'm trying to figure out how this would be done in practice, so as
Has any one done this before? It would seem to me that there should
I'm looking for a simple way to have this done. I would to have
This would be my issue I have a drop down that's not displaying fully.
I want to know how to set up a way to contact others without
This is the query I'm performing (without some Joins that are not relevant): SELECT
Linux environment. So, we have this program 't_show', when executed with an ID will
How I'm suppose to implement a macro that would do something like this: //pseudocode
I have done this: $ z() { echo 'hello world'; } How do I

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.