author -@himanshustwts

Let’s understand a few things beforehand before diving deep into it.

Threads

Threads are sequences of execution of code that can be executed independently without waiting for other tasks to finish.

It is the smallest unit of tasks that can be executed by an OS. A program can be single-threaded or multi-threaded.

Process

A program under execution is called a process. It can have multiple programs.

What is the difference between single-threaded and multi-threaded?

in single-threaded programs, only one task is executed at a time. In Multi-threaded architecture, multiple tasks are executed at a time.

single-threaded programs can be imagined as single lines going from the entry point of the application to its end while multi-threaded program is like a tree where the whole app starts from point 1 then it branches out more and more.

Python GIL:

Global Interpreter Lock

Python Interpreter is like a Virtual Machine. The thread is basically a POSEX or OS thread.