Re: volatile
- From: Timo Stamm <timo.stamm@xxxxxxxx>
- Date: Fri, 31 Mar 2006 17:09:49 +0200
Timo Nentwig schrieb:
I'm still not completely certain about the volatile keyword.
From cephas.net:
| 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.
The entire JSE 5 source (3,772,776 lines) uses the "volatile" modifier 111 times. According to my highly scientific analysis, you should not use the "volatile" keyword unless your code base is larger than 34,000 lines :-)
Timo Stamm
.
- Follow-Ups:
- Re: volatile
- From: Timo Nentwig
- Re: volatile
- References:
- volatile
- From: Timo Nentwig
- volatile
- Prev by Date: Class Loading on Different Opperating Systems
- Next by Date: Re: Reflecting generics
- Previous by thread: Re: volatile
- Next by thread: Re: volatile
- Index(es):
Relevant Pages
|