[concurrency-interest] Synchronization question

Ryan LeCompte Ryan.LeCompte at pangonetworks.com
Tue Jun 27 16:51:29 EDT 2006


Hello all,
 
I have a question regarding thread synchronization and referencing variables. Here's the rough description:
 
I have a class that has a non-volatile, private member variable. The class has a default no-arg constructor which doesn't do anything of importance. There is a synchronized method which gets invoked by the main thread, which assigns a value to the private member variable (non-primitive), among other things.
 
Then, I have another non-synchronized method which simply returns a reference to the private member variable (that's all it does). Multiple threads will ultimately invoke this non-synchronized method to get access to the variable. My question is this: is it possible that these other threads will not see the assignment made to the private member variable by the synchronized method? The system is written such that these other threads will NOT invoke the non-synchronized accessor method until the synchronized method is invoked. Do I want to make this private member variable volatile? Hopefully not.
 
Thanks!
 
Ryan
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060627/6f79e81e/attachment.html 


More information about the Concurrency-interest mailing list