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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:23:49+00:00 2026-06-09T11:23:49+00:00

I am a little confuse about how volatile variable effectively accesses from main memory.

  • 0

I am a little confuse about how volatile variable effectively accesses from “main” memory. How’s it different from a variable (non-volatile) that has a local copy ? What’s the typical workflow whenever multiple threads accesses a non-volatile vs a volatile variable ? I mean how do they work behind the scene ?

  • 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-09T11:23:51+00:00Added an answer on June 9, 2026 at 11:23 am

    Let’s say you have a variable that can be accessed by multiple threads.

    Thread 1 looks at the variable. Because looking at shared memory is more expensive than thread-local memory, it makes a copy of the variable. (Note that an object won’t be copied, just its reference.)

    Thread 2 looks at the same variable. It decides to change the variable. But Thread 1 doesn’t know it! Thread 1 is still using stale data. This is a Very Bad Thing. By making it volatile, each thread must look at the original variable when accessing it. They aren’t permitted to make local copies, so it won’t get stale.

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

Sidebar

Related Questions

I'm on my way learning about PDO from phpro.org, and a little bit confuse.
Still a little confused about Objective-C memory management. I think my confusion stems from
I am little bit confuse about log4j in grails. I need to log info
I'm a little confused about the HTTP protocol, from what i know HTTP was
--I haven't develop any iPhone Web Application ever...so i am little bit confuse about
So I'm a little confused about Qt's memory management. I was looking at the
I'm a little confused about how to do something that I thought would be
I am a little confused about memory clean up in an ASP.NET application. I
I am little confused about Java frameworks (I am coming from .NET). Do you
I'm a little confused about raising an event in Objective-C, I came from C#

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.