Thread Safety Via Read Only Collections

Posted by: youve been HAACKED, on 26 Mar 2007 | View original | Bookmarked: 0 time(s)

In a recent post I warned against needlessly using double check locking for static members such as a Singleton. By using a static initializer, the creation of your Singleton member is thread safe. However the story does not end there. One common scenario I often run into is having what is effectively a Singleton collection. For example, suppose you want to expose a collection of all fifty states. This should never change, so you might do something like this. public static class StateHelper { private...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: Data | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1202 | Hits: 399

Similar Posts

  • Turing Project: Level 100, 300 AND 400 more
  • WCF Proxy Generator - Significant Updates more
  • Pocket Kiosks brought to you by Microsoft Tag more
  • Timers in Silverlight 2.0 and Multithreaded Silverlight. more
  • Do NOT Explicitly Use Threads for Parallel Programming more
  • Active and Current (Stack Frame and Thread) more
  • A deadlock was detected while trying to lock variables more
  • Silverlight 2 Beta 1 Assemblies and Namespaces Part 2 the v2.0 subset more
  • Dispatch my stuff to the right thread more
  • Windows Workflow Foundation: MultiThreaded Parallelism more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD