
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 |