Skip to main content

Chapter 6: Thread safety and immutable collections

In this chapter

  • Concurrent collections
    • When should you use concurrent collections?
    • ConcurrentDictionary<TKey, TValue>
    • ConcurrentQueue<T> and ConcurrentStack<T>
    • ConcurrentBag<T>
  • Immutable design and collections
    • Building immutable custom types
    • Using System.Collections.Immutable collections
    • Build once, read many times: FrozenDictionary<TKey, TValue> and FrozenSet<T>
    • A pitfall to avoid: the default-value trap in ImmutableArray<T>
  • Quick reference for the collections in this chapter
  • Concurrent, immutable, or frozen: how should you choose?
  • Summary

This chapter is not available in the free preview. Purchase the book to read the complete edition now.

Buy this book