Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

volatile

 
devesh singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still I am not very clear with it ps tell me where do we use this and for what purpose
 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic