Ensures only one thread at a time can access a shared resource.
Back
Delegate vs Event
Front
...
Back
Thread
Front
Smallest unit of execution that can be independently scheduled by the OS
Back
Misc - Cores / Hyperthreading
Front
Hyperthreading - Every core has 2 isntruction pipelines, but only one execution engine
Hyperthreading improves performance by 30%
Every core improves performance by 70%
Back
Lock keyword
Front
Maps to the Monitor class
Back
Threads in all .NET Applications
Front
Garbage Collector thread: Responsible for the garbage collection.
Finalizer thread: Responsible to run the Finalize method of your objects.
Main thread: Responsible to run your main application's method.
UI thread: WinForms, WPF, and Windows Store applications have one thread dedicated to update the user interface.
Back
Interlocked Class
Front
Provides atomic operations for variables that are shared by multiple threads
Add, Read, Increment, Decrement, Exchange, CompareExchange
Back
Tasks in TPL
Front
Way to abstract away the need for threads from the programmer
Back
Atomic Operation
Front
Operation ca be started and finished as a single step without other threads interfering
Back
Parallel Classes
Front
For, ForEach, Invoke
Back
?? Operator
Front
Null-Coalescing Operator
Set y to the value of x if x is NOT null; otherwise, if x = null, set y to -1.
int y = x ?? -1;
Back
Race Condition
Front
When two threads try to update the same data
Back
Thread vs Threadpool
Front
1. All threads created from a Threadpool are background threads, manually created threads are foreground by default and can be set to background
2. Can't abort or interrupt a thread from the thread pool.
3. You can't join a thread from the thread pool.
4. Threads from the thread pool are reused when they finish their work, whereas the normal threads are destroyed.
5. You can't control the priority of a thread from the thread pool.