This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Java in General and the fly likes usage of volatile keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "usage of volatile keyword" Watch "usage of volatile keyword" New topic
Author

usage of volatile keyword

rajesh mohareer
Greenhorn

Joined: May 03, 2006
Posts: 2
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

Joined: Mar 06, 2001
Posts: 13459

Moving to the Java in General (intermediate) forum.

Dave
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18102
    
  39

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: usage of volatile keyword
 
Similar Threads
Volatile keyword
volatile keyword
volatile keyword
volatile keyword
Volatile Keyworld