|
-
August 13th, 2011, 11:46 PM
#4
Re: A few questions about thread safety
 Originally Posted by nuzzle
If a class is immutable it's threadsafe.
thats what I had been reading, and all the classes are truly immutable, once an instance is created it never changes, Anytime a change needs to be made, it returns a refernce to a new object. All I was worried about was if a read happened in the middle of an operation working on returning a new object. The read would read an object in a valid state I just wanted to make sure.
The more I think about it, if 2 different threads where working on making a change to the same object at the same time, both would still create valid objects even though I cant think of why someone would have to different threads update the same object, and if one thread is reading the object in the middle of an operation then that would be a race condition huh? as far as the tracking handles not being thread safe, thats not something I would look to taking care of in the class, that should be taken care of on the consumers end.
So just because its thread safe is there anything I am overlooking as to synchronization? or anything else that I may not have thought of?
Thanks,
Richard
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|