سؤال

I have read that ConcurrentDictionary only locks when writing, so the reads are lock free.

http://blogs.msdn.com/b/pfxteam/archive/2010/01/08/9945809.aspx reads on the dictionary are performed in a lock-free manner

But what about visibility, how do they ensure this when the reads are lock free?

هل كانت مفيدة؟

المحلول

The use of the MemoryBarrier ensures that the objects are 'published' for other threads. This does not require a lock.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top