Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Advatages of volatile variables  RSS feed

 
ragi singh
Ranch Hand
Posts: 198
Oracle Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
can anyone explain the advantages of using volatile variable
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using multiple processors, the value of a variable may be altered but not visible to other cores that may require the same variable.
Marking a variable as volatile allows the compiler and runtime to prevent optimisations and improve the variable visibility so that errors are not introduced at runtime caused by this.
Note that the restrictions caused by the volatile keyword can reduce the performance of the application when utilising this variable so some care should be taken.
 
siddhu Math
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Hope the link should help you , has quite a lot of information on volatile....volatile....

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!