Threading in .Net is an important topic. I have seen people unable to understand the nuances of processes, threads and how they are related in .Net and also in general.
In the series of articles around threading, I will try to present the concepts in the simplest way possible so that it can knock to your head directly and help you understand easily.
Threading is a broad topic that goes with operating systems. So before beginning the threading in .Net let's understand a few core or underlying concepts as in the following.
How applications and processes are related
When we start an application, system resources and memory are assigned to it. The separation of these boundaries are based on memory and the resources are called a process.
An application can be allocated one or more processes, where each process is differentiated based on allocated resources, data and execution code.
Processes
A process can be defined as an instance of the application. While running it uses assigned program code, system resources and data. A process further can be broken into more than one thread based on application design and the operating system of the machine.
Threads
A thread can be defined as the smallest possible part of the process that can be handled or controlled independently by a scheduler. If I make an analogy to it then you can relate it to atom in the world of matters/particles.
How processes and threads are related
Every thread is a part of a process. Multiple threads within a process share the memory, execution instruction, context data and other system resources.
The following picture explains the relationship among applications, processes and threads.
As said above, each process has its own execution instruction/sequence, context, memory and other system resources. The part or constituents that makes threads to work can be defined as in the following.
- Registers (in the CPU)
- Memory Stack
- Container to store threads state/context (in other words TLS)
TLS
I assume you understand what context switching is in threading. In simple words, it's switching the focus to various threads involved in the system based on certain algorithms (you might have heard of Round Robin and so on). In this scenario, the outgoing thread needs to store its state information to be able to start form the same place (again when it gets the slot). Basically this is done by TLS that uses a program counter that tells the thread which instruction to execute next.
Multithreading
Well, that's enough for the first tutorial. :) I will explain multithreading in the next article.
Please share your comments.


Prakash TripathiTOP 100Posted Jun 14, 2016, 7:34 PM EDT
Thnx a lot Shishir for finding them useful. I will keep on presenting the complex concepts into easy way.
Shishir RoyPosted Jun 14, 2016, 6:47 PM EDT
I gone thru almost all your docs. The way u represent the concept/logic its really appreciable.
Prakash TripathiTOP 100Posted Mar 6, 2016, 5:30 PM EST
Thnx Kumaresh
Prakash TripathiTOP 100Posted Mar 6, 2016, 5:30 PM EST
Thnx Karthiga.
Kumaresh RajalingamPosted Mar 6, 2016, 3:26 PM EST
good one
Kumaresh RajalingamPosted Mar 6, 2016, 3:26 PM EST
Nice explanation
Sr KarthigaPosted Mar 6, 2016, 3:14 PM EST
good one
Sr KarthigaPosted Mar 6, 2016, 3:14 PM EST
Nice explanation
Prakash TripathiTOP 100Posted Jan 21, 2016, 12:41 AM EST
Thnx SL.
Prakash TripathiTOP 100Posted Jan 21, 2016, 12:40 AM EST
Thnx PEDRO.
Prakash TripathiTOP 100Posted Jan 20, 2016, 11:40 PM EST
Thnx Narasimha.
Prakash TripathiTOP 100Posted Jan 20, 2016, 11:38 PM EST
Thnx Pankaj.
Prakash TripathiTOP 100Posted Jan 20, 2016, 11:35 PM EST
Thnx Humayun.
Prakash TripathiTOP 100Posted Jan 20, 2016, 11:33 PM EST
Thnx Gowtham.
Prakash TripathiTOP 100Posted Jan 20, 2016, 11:32 PM EST
Thnx Sibeesh.
Prakash TripathiTOP 100Posted Jan 20, 2016, 11:30 PM EST
Thnx Jaipal.
Jaipal ReddyPosted Jan 20, 2016, 7:17 PM EST
Nice article sir.
Sibeesh VenuTOP 100Posted Dec 28, 2015, 12:17 AM EST
Nice Share
Gowtham RajamanickamTOP 100Posted Dec 28, 2015, 12:10 AM EST
good..
Humayun Kabir MamunPosted Dec 6, 2015, 11:23 PM EST
Nice...
Pankaj Kumar ChoudharyTOP 100Posted Jul 19, 2015, 8:39 AM EDT
Nice Article Sir........
Narasimha Reddy ChennupalliPosted Jul 18, 2015, 10:09 AM EDT
Nice article
PEDRO RENE GONZALEZPosted Jun 6, 2015, 10:54 PM EDT
nice, thx
S LPosted Jun 6, 2015, 1:36 PM EDT
This is great, thank you for the content!
Prakash TripathiTOP 100Posted Jun 5, 2015, 10:27 PM EDT
You are welcome.
Santhakumar MunuswamyPosted Jun 5, 2015, 10:06 PM EDT
Thanks for nice article