File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes volatile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "volatile " Watch "volatile " New topic
Author

volatile

devesh singh
Greenhorn

Joined: May 08, 2001
Posts: 9
we say that volatile changes the orginal copy of the variable i.e
reading and writing on the variable produces changes in the master copy of he variable
so does this also not happen in the case of static variable
I think ia hve got wring notions of the volatile variable
ps anyone expalin me the details of volatile keyword.
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Here is the definition for volatile kerword:
Volatile is a Java programming language keyword used in variable declarations that specifies that the variable is modified asynchronously by concurrently running threads.
Roopa
Originally posted by devesh singh:
we say that volatile changes the orginal copy of the variable i.e
reading and writing on the variable produces changes in the master copy of he variable
so does this also not happen in the case of static variable
I think ia hve got wring notions of the volatile variable
ps anyone expalin me the details of volatile keyword.

nishesh chouhan
Ranch Hand

Joined: Nov 06, 2000
Posts: 37
still I am not very clear with it ps tell me where do we use this and for what purpose
Charlie Swanson
Ranch Hand

Joined: Jan 29, 2001
Posts: 213
Volatile tells the computer that a variable may change asynchronously due to threads. Declaring a variable to be volatile makes the compiler forego optimizations that might turn the variable into a constant and eliminate the possibility of it changing asynchronously. "from Java 2 by Barry Boone/William Stanek"
Definition of asynchronously: unsynchronized events, for example, the time interval between event A and B is not the same as B and C. " from The Computer Glossary"
Also, as per RHE book, volatile is not an the exam.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: volatile