aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Volatile keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Volatile keyword" Watch "Volatile keyword" New topic
Author

Volatile keyword

Lokanadham Nalla
Greenhorn

Joined: Jul 21, 2005
Posts: 7
Hi,

Could explain what is the use of volatile keyword in java. I have read it many places but I am always confused with it.

Thank you.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Check this.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
if the variable is declared as volatile then the it means that each thread will have a copy of that variable ......

thanks & regards

srikanth reddy
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
Originally posted by srikanth reddy:
if the variable is declared as volatile then the it means that each thread will have a copy of that variable ......

thanks & regards

srikanth reddy


Actually the volatile meaning is oposite. Volatile variable does have only one master copy and threads access it directly.

Non-volatile variables may or may not (depends on JVM) have a private copy for each thread. The private copies are synchronized with the master copy only at certain points.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Volatile keyword