Skip to content

Lesson 11. Multithreading

kudriako edited this page Apr 9, 2019 · 7 revisions

Processes and Threads

An application consists of one or more processes. A process, in the simplest terms, is an executing program. One or more threads run in the context of the process. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the process code, including parts currently being executed by another thread. https://docs.microsoft.com/en-us/windows/desktop/procthread/processes-and-threads

History

Interruptions, DMA and controllers

Deadlocks and race conditions

A deadlock in C# is a situation where two or more threads are frozen in their execution because they are waiting for each other to finish

A race condition occurs when two or more threads are able to access shared data and they try to change it at the same time.

Multithreading in .NET

Thread сlass

https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread?view=netframework-4.7.2

Exception handling

AppDomain.UnhandledException

Interlocked сlass

Operator 'lock'

Monitor сlass

Mutex

Semaphore

AutoResetEvent class

ManualResetEvent class

ThreadPool

BackgroundWorker

Timers

SynchronizationContext

Thread-Safe Collections

https://docs.microsoft.com/en-us/dotnet/standard/collections/thread-safe/

Clone this wiki locally