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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:32:19+00:00 2026-06-03T06:32:19+00:00

what is the difference in using volatile keyword in java4 and java5 onwards? and

  • 0

what is the difference in using volatile keyword in java4 and java5 onwards?

and related to that,

Read/write operations on non-atomic variables(long/double) are atomic when they are
declared as volatile.

Is this also true for java4 or it is valid from java5 onwards???

  • 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-03T06:32:20+00:00Added an answer on June 3, 2026 at 6:32 am

    People have provided good points and references responding to my question answering first part.

    Going specific to the second part of question, this i read at some forum:

    A volatile declared long is atomic (pre-Java 5 also) in the sense that
    it guarantees (for all JVM implementations) a read or write go
    directly to main memory instead of two 32-bit registers.

    And

    Pre-Java 5, volatile was supposed to provide such guarantees for long
    and double. However things did not work out this way in practice, and
    implementations frequently violated this guarantee. As I recall the
    issue seemed to get fixed around JDK 1.4, but as they were still
    working on the whole memory model thing, they didn’t really make any
    clear announcements about it until JDK 5, when the new rules were
    announced, and memory guarantees actually meant something.

    And this is from Java Language Specification,Second Edition:

    17.4 Nonatomic Treatment of double and long

    The load, store, read, and write actions on volatile variables are atomic,
    even if the type of the variable is double or long.

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

Sidebar

Related Questions

I understand the volatile keyword in Java can make the read/write operations of reference
Is there a difference between using a lock object that is declared as a
Is there any difference in using login_required decorator in urls.py and in views.py ?
What is the difference between using the OnClick attribute of an ASP.Net Button: <asp:Button
What is the difference between using an environment variable, like PATH, as $PATH or
what's the difference between using a js library like jquery and using an ajax
Is there a difference between using tearDown and setUp versus __init__ and __del__ when
Whats the difference between using a LEFT OUTER JOIN , rather than a sub-query
In PHP what is the difference between using \1 or $1 as $replacement in
Can anyone tell me the difference between using mod_deflate and zlib output_compression? I understand

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.