Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

volatile keyword

 
ShivaKumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the significance of volatile keyword in java?
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Volatile forces variable modifications to be visible to multiple threads. It's not something that the average Java programmer will ever have to worry about.
But if you start doing a lot of concurrent programming, you will probably use this. It's one way of allowing concurrent access to a variable by multiple threads without having to use synchronization locks, which can speed up a program's execution. It works best for optimizing situtiations where one thread is writing to a variable, and multiple threads are reading from that same variable.
[ April 02, 2002: Message edited by: Rob Ross ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ShivaKumar,

Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy. (You need to have a space in there).
Thanks again and we hope to see you around the ranch!!
Cindy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic