# Process vs Thread

Each thread executing in a process will have its own stack. If there is 8 thread in a process there will be 8 stacks assigned.

In order to distinguish the concept of a process from a thread, think about a process as the container and a thread as something inside the container. When you execute an application, Windows OS creates the process which is identified by a virtual address space in memory where all the executable and non-executable modules/resources needed are mapped. The OS also creates at least one thread that's ready for execution.

In fact, every process has its own virtual address space, but multiple threads inside the same process share the same virtual address space - the one of the process they belong to.

On the other hand, the term thread can indicate the time- slice assigned by the processor to that specific process in order to execute a portion of instructions inside it.

In other words, in a single-processor system, only one thread can be executed at a time, but on a multi-processor or multi-core system it is possible to have as many threads running simultaneously as the number of cores.

Of course, all this depends on the way the operating system uses the available resources.

In other words, it is the operating system that assigns the various threads to the available processors, in order to actually take advantage of the presence of more than one processors.

Remember a few years ago when only single-core processors were available, and you could still run many programs at once?

In reality, the processor was assigning a time-slice for execution on each thread at the time, but due to the speed with which this was done, you thought that all applications were running at the same time.

Actually, the same thing happens today. You might have a quad-core processor, but you aren't limited to four processes running at the same time.

The illusion of simultaneous execution of multiple applications at the same time is called multitasking. Having multiple threads that actually run in parallel is called multithreading
