Link Details

Link 89811 thumbnail
User 71517 avatar

By Volume4
via dotnet.dzone.com
Published: Jun 24 2008 / 16:14

In .NET 2.0 and above the SyncRoot was removed from the Dictionary and Hastable classes which meant you can't create thread-safe versions of these anymore. So here I provide a simple implementation of a generic synchronised dictionary class that is thread-safe, this was developed in .NET 3.5 using the new Threading.ReaderWriterLockSlim class.
  • 9
  • 2
  • 972
  • 88

Comments

Add your comment
User 254975 avatar

isuttle replied ago:

0 votes Vote down Vote up Reply

This is great, except for it's not true. Hashtable continues to have SyncRoot, and generic Dictionaries are threadsafe when static/shared.

User 309292 avatar

bigtoe replied ago:

0 votes Vote down Vote up Reply

Sorry your sadly mistaken. Generic Dictionaries are not thread safe when declare shared/static.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (9)



Voters Against This Link (2)