aspose file tools*
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
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: 18896
    
  40

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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: usage of volatile keyword