I am reading about const
and thread safety in C++11, here is a relevant question, and here is also a video by Herb Sutter. The word "synchronized" is often mentioned. But what does "synchronized" exactly mean?
For example, the follwing two lines are from Herb's video
"copying from the same object in multiple threads without synchronization" (at 13:40)
"... A const object is fully thread-safe(truly immutable or internally synchronized)" (at 15:03)
Answer
Synchronization means sharing of resources between threads and processes without leading to race around conditions and dead locks.
Without synchronization in 1st statement means that it does not lock the resource and unlock it when it is done.
In second statement he means to say as it is a const object it cannot be modified and is hence perfectly immutable and doesn't need synchronization.
A study on thread synchronization techniques using Mutex and Semaphore will help you better understand why it is needed and how it is done.
No comments:
Post a Comment