File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java 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 » Java » Beginning Java
Bookmark "volatile keyword" Watch "volatile keyword" New topic

volatile keyword


Joined: Apr 02, 2002
Posts: 1
what is the significance of volatile keyword in java?
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
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 ]

SCJP 1.4
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521

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!!

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: volatile keyword
It's not a secret anymore!