开发者

Is there a c# equivalent of Java ConcurrentHashMap

I need a dictionary/hashmap in c# that allow you to do the following

  1. put values and iterate at the same time without a lock
  2. lock only put. get are no开发者_如何转开发t locked and you may get many times concurrently

Thanks


Have a look at the ConcurrentDictionary here: http://msdn.microsoft.com/en-us/library/dd287191.aspx. This should do what you're looking for. Keep in mind, it's .Net 4 only.


check out the System.Collections.Concurrent - Namespace! http://msdn.microsoft.com/en-us/library/system.collections.concurrent.aspx


That sounds like ConcurrentDictionary<TKey, TValue> to me, available in .NET 4.0 or .NET 3.5 if you've installed Reactive Extensions.


You could also write your own class by using the ReaderWriterLockSlim Class.

Otherwise simply take a look into the System.Collections.Concurrent Namespace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜