Why use volatile variables in java ?

Can anyone make me clear about use of volatile keyword in java ? I would appreciate if one can give related examples ?
Thanks in advance

Replies

  • Anoop Kumar
    Anoop Kumar
    never used volatile variables in real project.
    you can see some stackoverflow discussion, they have some practical examples

    #-Link-Snipped-#

    This discussion is very clear why volatile

    #-Link-Snipped-#
  • Dhaval Pujara
    Dhaval Pujara
    volatile modifier tells the JVM that a threbad accessing a the variable must always reconcile its own private coppy of the variable with master copy in memory ......ALL IN ONE THAT STOP ACCESSING MULTIPLE THREAD TO INSTANCE VARIABLE VOLATILE IS USED ultimatly its only applied to instance variable not local variable

You are reading an archived discussion.

Related Posts

It looks like this years recruitment is being ruled by Accenture which is making big bulk offers to the students. At VIT aka Vellore Institute Of Technology, Accenture recruited about...
CEans, this thread is meant to act as the campus recruitment tracker for all the placement offers made in campuses in year 2014. Please post information about the companies that...
Hello Engineers, This post is about a Walking Mechanism made by Theo jansen, a kinematic sculptor. Theo has used his creativity and bridgred the gap between art and engineering through...
hi friends can any one tell me how to stop unwanted mail coming from inbox to which i have subscribed earlier. but still the mail from those sites are coming...
Volkswagen India, the German car manufacturer, has today launched its compact hatchback Polo's new variant - the Volkswagen Polo GT TDI. Powered by the 1.6-litre 4-cylinder turbo-diesel engine that features...