SlideShare a Scribd company logo
2
Most read
15
Most read
19
Most read
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
www.edureka.co/python
What is Multitasking in Python?
What is a thread?
How to achieve Multithreading in Python?
When to use Multithreading in Python?
How to create Threads in Python?
• Without creating a class
• By extending Thread class
• Without extending Thread class
Advantages of Multithreading
Types of Multitasking
What is Multitasking in Python? www.edureka.co/python
www.edureka.co/python
What is
Multitasking in
Python?
Multitasking refers to the ability of an operating system to perform
different tasks at the same time
Types of Multitasking www.edureka.co/python
www.edureka.co/python
Types of
Multitasking
Process Based
Multiple threads
running on the same
OS simultaneously.
Example:
Downloading, listening
to songs and playing a
game..
01
Thread Based
Single process
consisting of
separate tasks.
Example: A game of
FIFA consists of
various threads.
.
02
There are two types of multitasking in an OS:
www.edureka.co/python
What is a Thread? www.edureka.co/python
www.edureka.co/python
What is a Thread?
Thread 1 Thread2
Main Code
Thread 3 … Thread n
How to Achieve Multithreading in Python?www.edureka.co/python
Multithreading in Python can be achieved by importing the threading module.
www.edureka.co
How to Achieve Multithreading in Python
conda install -c conda-forge tbb
Importing
importthreading
fromthreadingimport*
www.edureka.co/python
When to use Multithreading in Python?www.edureka.co/python
www.edureka.co/python
When to use
Multithreading
in Python?
Multithreading in Python can be used
when:
Multiple tasks need to achieved
Tasks do not have interdependency.
How to Create Threads in Python? www.edureka.co/python
www.edureka.co/python
How to Create Threads in Python?
01 Without creating a class
02By extending Thread class
03 Without extending Thread class
www.edureka.co/python
Without creating
a class
from threading import *
print(current_thread().getName())
def mt():
print("Child Thread")
child=Thread(target=mt)
child.start()
print("Executing thread name
:",current_thread().getName())
www.edureka.co
By extending Thread class
import threading
import time
class mythread(threading.Thread):
def run(self):
for x in range(7):
print("Hi from child")
a = mythread()
a.start()
time.sleep(1)
print("bye",current_thread().getName
())
www.edureka.co/python
www.edureka.co/python
Without
extending Thread
class
from threading import *
class ex:
def myfunc(self):
for x in range(7):
print("Child")
myobj=ex()
thread1=Thread(target=myobj.myfunc)
thread1.start()
#threading.active_count()
thread1.join()
thread1.join()
print("done")
www.edureka.co/python
Advantages of Multithreading www.edureka.co/python
Advantages of
Multithreading
Enhanced performance by decreased development time
Simplified and streamlined program coding
Simultaneous and parallelized occurrence of tasks
Better use of CPU resource
www.edureka.co/python
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
www.edureka.co/python

More Related Content

What's hot (20)

PPT
Introduction to Python
Nowell Strite
 
PDF
Python libraries
Prof. Dr. K. Adisesha
 
PDF
Python multithreaded programming
Learnbay Datascience
 
PDF
Set methods in python
deepalishinkar1
 
PPTX
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
PDF
Datatypes in python
eShikshak
 
PPTX
Object Oriented Programming in Python
Sujith Kumar
 
PPTX
Python: Modules and Packages
Damian T. Gordon
 
PPS
Wrapper class
kamal kotecha
 
ODP
Python Modules
Nitin Reddy Katkam
 
PPTX
Beginning Python Programming
St. Petersburg College
 
PDF
Class and Objects in Java
Spotle.ai
 
PDF
Generics
Ravi_Kant_Sahu
 
PPTX
Chapter 05 classes and objects
Praveen M Jigajinni
 
PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPTX
Operator Overloading In Python
Simplilearn
 
PPTX
Conditional and control statement
narmadhakin
 
Introduction to Python
Nowell Strite
 
Python libraries
Prof. Dr. K. Adisesha
 
Python multithreaded programming
Learnbay Datascience
 
Set methods in python
deepalishinkar1
 
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Datatypes in python
eShikshak
 
Object Oriented Programming in Python
Sujith Kumar
 
Python: Modules and Packages
Damian T. Gordon
 
Wrapper class
kamal kotecha
 
Python Modules
Nitin Reddy Katkam
 
Beginning Python Programming
St. Petersburg College
 
Class and Objects in Java
Spotle.ai
 
Generics
Ravi_Kant_Sahu
 
Chapter 05 classes and objects
Praveen M Jigajinni
 
Chapter 07 inheritance
Praveen M Jigajinni
 
Operator Overloading In Python
Simplilearn
 
Conditional and control statement
narmadhakin
 

Similar to What is Multithreading In Python | Python Multithreading Tutorial | Edureka (20)

PPTX
Introduction to python lecture (1)
Ali ٍSattar
 
PPTX
Python basics
ssuser4e32df
 
PDF
Python_Interview_Questions.pdf
Samir P.
 
PPTX
python programming.pptx
Kaviya452563
 
PDF
DevOps - A Purpose for an Institution.pdf
Vishwas N
 
PPTX
python presntation 2.pptx
Arpittripathi45
 
PDF
Introduction to python
Mohammed Rafi
 
PDF
Most Asked Python Interview Questions and Answers in 2023
Instaily Academy
 
PDF
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdf
RahulSingh190790
 
PDF
Python Interview Preparation questons...
harshitgupta20022005
 
PPTX
introduction to Python (for beginners)
guobichrng
 
PDF
Handson Python
AkramWaseem
 
PPTX
Python_Introduction&DataType.pptx
HaythamBarakeh1
 
PPTX
Python Language Overview
ShobhitNuwal1
 
PPTX
Introduction to python
AnirudhaGaikwad4
 
PPT
Distributed systems Chapter 3-Processes.ppt
shambelworku8
 
PPTX
Getting Started with Python
Sankhya_Analytics
 
PPTX
Lacture 1- Programming using python.pptx
hello236603
 
PDF
Python3handson
VetriSelvan Nagarajan
 
PPTX
Python Introduction Presentation Part -1
CSC
 
Introduction to python lecture (1)
Ali ٍSattar
 
Python basics
ssuser4e32df
 
Python_Interview_Questions.pdf
Samir P.
 
python programming.pptx
Kaviya452563
 
DevOps - A Purpose for an Institution.pdf
Vishwas N
 
python presntation 2.pptx
Arpittripathi45
 
Introduction to python
Mohammed Rafi
 
Most Asked Python Interview Questions and Answers in 2023
Instaily Academy
 
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdf
RahulSingh190790
 
Python Interview Preparation questons...
harshitgupta20022005
 
introduction to Python (for beginners)
guobichrng
 
Handson Python
AkramWaseem
 
Python_Introduction&DataType.pptx
HaythamBarakeh1
 
Python Language Overview
ShobhitNuwal1
 
Introduction to python
AnirudhaGaikwad4
 
Distributed systems Chapter 3-Processes.ppt
shambelworku8
 
Getting Started with Python
Sankhya_Analytics
 
Lacture 1- Programming using python.pptx
hello236603
 
Python3handson
VetriSelvan Nagarajan
 
Python Introduction Presentation Part -1
CSC
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Python Programming Tutorial | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 

What is Multithreading In Python | Python Multithreading Tutorial | Edureka