wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Volatile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Volatile" Watch "Volatile" New topic


Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
Hi all,
Volatile is used for a variable which can be modified asynchronously. How can modify a variable asynchronously?
Please help
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

This modifier is used to identify a variable which can be modifed by different threads. So 'volatile' is suppose to tell the compiler to not perform certain optimizations on the variable.
So for example: you make two instances of ThreadClassA. In ThreadClassA there is a variable named 'VolatileTemp'. Each instance of TheadClassA can than change 'VolatileTemp' at will.
Did that answer your question in anyway?

Please ignore post, I have no idea what I am talking about.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Volatile
Similar Threads
Transient variables
transient volatile strictfp 's position in SCJP1.4!
volatile confusion
What should I use instead of Thread.stop?