- provides a pool of threads
- can be used to execute tasks
- post work items
- process asynchronous I/O
- process timers
Further read:
https://learn.microsoft.com/en-us/dotnet/api/system.threading.threadpool?view=net-6.0
Further read:
https://learn.microsoft.com/en-us/dotnet/api/system.threading.threadpool?view=net-6.0
async
programmingFurther read:
https://learn.microsoft.com/en-us/dotnet/standard/parallel-programming/task-parallel-library-tpl
In short:
it will not work because it requires boxing and boxing will create new object for reference in lock
every time code is executed so lock statement will not prevent anything.
Further read:
https://intellitect.com/blog/locking-a-block-of-code-with-an-integer/
lock
statement blocks execution of a code block for single thread that hold locklock
statements may lead to deadlockBelow code block is translated by compiler
lock (x) { // Your code... }
to:
object __lockObj = x; bool __lockWasTaken = false; try { System.Threading.Monitor.Enter(__lockObj, ref __lockWasTaken); // Your code... } finally { if (__lockWasTaken) System.Threading.Monitor.Exit(__lockObj); }
Further read:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock
Further read:
https://www.c-sharpcorner.com/article/task-and-thread-in-c-sharp/