This discussion is archived
3 Replies Latest reply: May 26, 2012 5:48 PM by jtahlborn RSS

Volatile Objects

761757 Newbie
Currently Being Moderated
Hi All,

Recently while going through language spec for Java 7 , I was reading about the volatile object. I just remembered that in 1st edition of Java specification , there was a section about 'Rules Of Volatile variable'

I was able to find that PDF in my repository and it said something like :

An use action by T on V is permitted only if the previous action by T on V was
load, and a load action by T on V is permitted only if the next action by T on V
is use. The use action is said to be “associated” with the read action that corresponds
to the load.
• A store action by T on V is permitted only if the previous action by T on V was
assign, and an assign action by T on V is permitted only if the next action by T
on V is store. The assign action is said to be “associated” with the write action
that corresponds to the store.

But as of now there was no reference of them in this latest version (didn't find them even in specification of Java 5) , do they still hold good?

I understand with concurrency and atomic concepts in place with JDK , volatile object might not be used much these days . But just wanted to be sure of it , if in case I find a reason to use it.

Thanks

Edited by: user10079576 on May 26, 2012 3:37 AM
  • 1. Re: Volatile Objects
    EJP Guru
    Currently Being Moderated
    What do you mean 'no reference'? What do you call section 8.3.1.4?
  • 2. Re: Volatile Objects
    796440 Guru
    Currently Being Moderated
    Also note that, contrary to your subject line, there's no such thing as a "volatile object." It's variables that can be volatile, not the objects they point to. It's important to understand the distinction.
  • 3. Re: Volatile Objects
    jtahlborn Expert
    Currently Being Moderated
    user10079576 wrote:
    I understand with concurrency and atomic concepts in place with JDK , volatile object might not be used much these days . But just wanted to be sure of it , if in case I find a reason to use it.
    actually, when the volatile semantics were strengthened in the new memory model introduced with jdk 5, volatile became much more useful. many of the new concurrency utilities are based on volatile references (internally).

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points