From the course: Advanced C#: Thread-Safe Data with Concurrent Collections

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Collections and threads

Collections and threads

- [Narrator] Most computers and devices today are capable of running multiple threads. This is accomplished with multiple processors, multi-core processors or hyperthreading processes because of this modern programs can allocate work across multiple threads. Microsoft has built a nice set of tools to make threading easier. For example, there are the classes like the task and parallel classes that handle thread creation for us. They have built in synchronization and handle callbacks in an easy fashion. This is certainly better than creating threads manually or using the .Net ThreadPool directly and the async and await keywords in C# and visual basic definitely helped detangle the code in the editor. While these tools make it easier and cleaner to write multi-threaded applications, they don't automatically make your code thread safe however, we still need to consider how the threads interact with our objects, For example,…

Contents