-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Martin,
Martin Gainty wrote:
> after discussing a few scenarios I came upon the idea of
> volatile is to be used as a default declarator (if only for speed..)
Volatile can do nothing but /decrease/ the speed of variable access.
Actually, most JVMs do
Sorry Martin,
but using volatile will not make your code any thread-safer.
Volatile (if implemented at all by your VM) will ensure that all
threads sees the "central" copy instead of their own copy. It won't
prevent you from concurrent modification.
Example:
public MyThread{
private boolean run
I was not advocating volatile as a means of ensuring Thread safety
but more to the side effect of gaining performance
I am a strong personal advocate of synchronized but some of the leads dont
want to go that route
as it would be too intrusive to re-factor the existing base for the may
method
after discussing a few scenarios I came upon the idea of
volatile is to be used as a default declarator (if only for speed..)
ThreadLocal is to be used for complex DataObjects whose size may 'grow' over
time
in this way ThreadLocal guarantees proper initialisation of the entire
object
Lighter (
--- Martin Gainty <[EMAIL PROTECTED]> wrote:
> In a StrutsApplication is it best to use delcare
> variables with volatile OR ThreadLocal to ensure
> variables are referenced in a ThreadSafe manner?
Which variables, and what types?! (Note mild alarm.)
Are you attempting to share data, or ensure th
5 matches
Mail list logo