Link to home
Start Free TrialLog in
Avatar of JohnSantaFe
JohnSantaFe

asked on

Thread synchronization needed for read only data?

I have an application with two threads in addition to the main thread.  There is a shared data resource which consists of a bunch of configuration parameters.  The main application determines all the parameters and then creates the other two threads.  Once established the parameters never change, however they are used by all three threads.

Do I still need to implement synchronization e.g. a mutex to protect the data, or since it never chages, locking is not necessary?  Or another way to put it, is it ok to have multiple threads read data at the same time without locking it?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should make the data constant, or access the data from the multiple threads using a constant type, so as to make sure the object is not calling a member that might be modifying the object.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JohnSantaFe
JohnSantaFe

ASKER

Thanks for the info and validation.