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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:24:28+00:00 2026-05-29T11:24:28+00:00

I’m aware of the use of volatile in Java. That is (based on the

  • 0

I’m aware of the use of volatile in Java.
That is (based on the wikipedia article):

There is a global ordering on the reads and writes to a volatile
variable. This implies that every thread accessing a volatile field
will read its current value before continuing, instead of
(potentially) using a cached value.

I also I’m aware that there exists the volatile keyword in C but in a quite different context, mainly to be used in memory-mapped I/O.

So I was wondering, is there some construct like Java’s volatile in C? Which will prevent
reading cached values of a variable?

If it doesn’t exist in C, is there perhaps a library with such a construct, like pthread?

  • 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-29T11:24:28+00:00Added an answer on May 29, 2026 at 11:24 am

    volatile in C is basically an anachronism that was intended for a completely different scenario and is NOT useful for multi threaded programming. For some reasons or another even the newest c++ standard couldn’t give it more meaning but had to invent a new keyword instead.

    Mind you this means volatile as defined by the C standard is useless, compilers may give you additional guarantees (I know that MS VC does and I think it gives basically the same guarantees as does volatile in java) but that means the program is locked to that one compiler. Most compilers also have some intrinsics to insert memory barriers, which is a bit more explicit but again not portable per se.

    In practice you’re probably best of using some higher level threading library that offers the right tools for the job. E.g. POSIX gives you low level memory barriers afaik.

    On the c++ site it’s better since 0x11 – the standard does offer std::atomic_thread_fence and atomic variables. Note though that the c++0x11 memory model is NOT identical to the java one, so you’ll have to be careful when porting.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.