Java Programming/Keywords/volatile
Appearance
volatile
is a keyword.
When member variables are marked with this keyword, it changes the runtime behavior in a way that is noticeable when multiple threads access these variables. Without the volatile keyword, one thread could observe another thread update member variables in an order that is not consistent with what is specified in sourcecode. Unlike the synchronized keyword, concurrent access to a volatile field is allowed.
Syntax:
private
volatile
<member-variable>; orvolatile
private
<member-variable>;
For example:
private volatile changingVar;
|
See also: