This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.
I agree. Here's the link:
subject: Volatile
Similar Threads
Transient variables
transient volatile strictfp 's position in SCJP1.4!
volatile confusion
What should I use instead of Thread.stop?