Discussione: [Java 1.5.x] volatile
View Single Post
Old 21-12-2006, 18:14   #3
^TiGeRShArK^
Senior Member
 
L'Avatar di ^TiGeRShArK^
 
Iscritto dal: Jul 2002
Cittā: Reggio Calabria -> London
Messaggi: 12112
Ecco una sintetica spiegazione:
Quote:
The volatile modifier requests the Java VM to always access the shared copy of the variable so the its most current value is always read. If two or more threads access a member variable, AND one or more threads might change that variable's value, AND ALL of the threads do not use synchronization (methods or blocks) to read and/or write the value, then that member variable must be declared volatile to ensure all threads see the changed value.
__________________
^TiGeRShArK^ č offline   Rispondi citando il messaggio o parte di esso