| Author |
Volatile - synchronized ?
|
kri shan
Ranch Hand
Joined: Apr 08, 2004
Posts: 1300
|
|
|
Can i specify volatile variable within synchronized method or synchronized block ? Volatile works only with multithreaded code(non thread-safe) ?
|
 |
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
|
|
volatile is a modifier that only applies for instance and class variables.
It makes that different Threads do not cache the value of the corresponding variable and hence always retrieve the latest, up-to-date, could-have-been-modified-by-another-thread value.
|
JDBCSupport - An easy to use, light-weight JDBC framework -
|
 |
Monu Tripathi
Rancher
Joined: Oct 12, 2008
Posts: 1365
|
|
|
If you are interested in understanding Synchronization and about volatile modifier and if you have time, consider reading Synchronization and Java Memory Model.
|
[List of FAQs] | [Android FAQ] | [My Blog] | [Samuh Varta]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32687
|
|
|
Probably best moved to the threads forum.
|
 |
Nitish Bangera
Ranch Hand
Joined: Jul 15, 2009
Posts: 536
|
|
|
One thing to note, there is only one non access modifier for local variables and that is final. There are no other non access modifiers for local variables.
|
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
|
 |
 |
|
|
subject: Volatile - synchronized ?
|
|
|