
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Thread-Safe collections in C#
The .NET Framework 4 introduced System.Collections.Concurrent namespace. The namespace has numerous collection classes. These classes are both thread-safe and scalable. Multiple threads can safely add or remove items from these collections,
The following concurrent collection types use lightweight synchronization mechanisms: SpinLock, SpinWait, etc. These are new in .NET Framework 4.
Let us see the concurrent collection in C# −
Sr.No. | Type & Description |
---|---|
1 | BlockingCollection<T> Bounding and blocking functionality for any type. |
2 | ConcurrentDictionary<TKey,TValue> Thread-safe implementation of a dictionary of key-value pairs. |
3 | ConcurrentQueue<T> Thread-safe implementation of a FIFO (first-in, first-out) queue. |
4 | ConcurrentStack<T> Thread-safe implementation of a LIFO (last-in, first-out) stack. |
5 | ConcurrentBag<T> Thread-safe implementation of an unordered collection of elements. |
6 | IProducerConsumerCollection<T> The interface that a type must implement to be used in a BlockingCollection |
- Related Articles
- Make your collections thread-safe in C#
- Thread Safe Concurrent Collection in C#
- Is Swing thread-safe in Java?
- How to understand StringBuffer is thread-safe and StringBuilder is non-thread-safe in Java?\n
- Is Java matcher thread safe in Java?
- Which collection classes are thread-safe in Java?
- How to make a collection thread safe in java?
- How to make a class thread-safe in Java?
- Check if ArrayList is Synchronized (thread safe) in C#
- Do you think a Python dictionary is thread safe?
- Difference between Traditional Collections and Concurrent Collections in java
- Collections in C#
- Multidimensional Collections in Java
- Collections in Java\n
- Indexed collections in JavaScript
