Introduction to multi-threading with Python

Introduction to multi-threading with Python

A process is a running instance of any program which consumes CPU time. And a fragment of a process that can run independently is a thread.

A process is a running instance of any program which consumes CPU time. And a fragment of a process that can run independently is a thread.

Image for post

If we look closely at these statistics of a computer at one instance (point). We can see 2640 threads and (196 processes) are running on 4 cores. So how does this happen?

Image for post

For understanding, let us consider an example. A typical quad-core CPU comprises 4 processing cores, on a single chip. Now, this bunch of (2640) threads relies on these 4 cores, for execution. But at any point, at most, they can execute only 4 threads (1 thread in each core). This is when cores start switching between threads, to counter this problem.

Each core will start running multiple threads, one by one. Executing thread t1 (say) at one instant, then thread t2(say) in the next instant, and so on. But this switching happens at lightning speed, in nanoseconds.

coding programming python

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

top 30 Python Tips and Tricks for Beginners

In this post, we'll learn top 30 Python Tips and Tricks for Beginners

50+ Basic Python Code Examples

In this tutorial, we'll learn 50+ Basic Python Code Examples.List, strings, score calculation and more..

Guide to Python Programming Language

Guide to Python Programming Language

Lambda, Map, Filter functions in python

You can learn how to use Lambda,Map,Filter function in python with Advance code examples. Please read this article

Using Black To Auto Format Your Python

In this post, we'll learn how to stop worrying and embrace Auto Formatting in your python code.