Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

usage of volatile keyword

 
rajesh mohareer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i am rajesh i am new to this forum.

i have a question

Can i know the usage of volatile keyword in the java?


Awaiting for your response


Thanks
Rajesh
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Java in General (intermediate) forum.

Dave
 
Henry Wong
author
Marshal
Pie
Posts: 21123
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rajesh mohareer:
hi i am rajesh i am new to this forum.

i have a question

Can i know the usage of volatile keyword in the java?

Awaiting for your response

Thanks
Rajesh


When a static or instance variable is declared as volatile, the compiler will generate code that... (1) will not cache or perform other optimization with it. Every usage will be a read from memory, and every assignment will immediately write to memory. And (2), every read and write will be assured as atomic. For most data types, reading and writing are normally atomic, so this will only affect the long and double types.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic