Python Tutorial – 26. Multithreading – Introduction

///Python Tutorial – 26. Multithreading – Introduction

Python Tutorial – 26. Multithreading – Introduction

FavoriteLoadingAdd to favorites

This tutorial covers what is multi-threading and then shows how to create multiple threads in python program. It explains what is multithreading with examples, how to import the threading module and how to implement multi-threading.

Topics that are covered in this Python Video:
0:00 What is multithreading?
1:49 Example of multithreading
5:20 Import threading module and implementing multi-threading

Code used in this tutorial:

Next Video:
Python Tutorial – 27. Multiprocessing Introduction:

Website:
Facebook:
Twitter:
Patreon:

source

By |2020-12-10T11:08:15+00:00December 10th, 2020|Python Video Tutorials|48 Comments

48 Comments

  1. codebasics December 10, 2020 at 11:08 am - Reply
  2. Ashish Singh Baghel December 10, 2020 at 11:08 am - Reply

    This was my output (messd up) 🙁

    “`
    calculate square of numbers

    calculate cube of numbers

    square:cube: 4

    8

    square: 9

    cube: 27

    cube:square: 64

    512

    square:cube: 81729

    done in : 0.8602502346038818

    Hah… I am done with all my work now!
    “`

  3. newlinks December 10, 2020 at 11:08 am - Reply

    great explanation

  4. Nikhil Patil December 10, 2020 at 11:08 am - Reply

    73 Dislike can't believe if you don't understand anything just comment someone will answer you.

  5. Dishant Kumbhar December 10, 2020 at 11:08 am - Reply

    In thonny IDE , run time had doubles 😂.
    I don't know what's the reason but failing in thonny🤣

  6. EDWARD CHAVEZ December 10, 2020 at 11:08 am - Reply

    if i want to get data from t1, in case t1 was in another class, how i can get that data

  7. puneet gajwal December 10, 2020 at 11:08 am - Reply

    Cut this music, I couldn't stand it for a minute

  8. Chandradhar Rao December 10, 2020 at 11:08 am - Reply

    Your explanation on threading was awesome!!

  9. Sambath Narayanan Parthasarathy December 10, 2020 at 11:08 am - Reply

    Teaching CS through story telling ! Brilliant that is the way to …

  10. Bhavin Patel December 10, 2020 at 11:08 am - Reply

    Good job man. Specifically, real examples you use are always interesting. 😀😀😀

  11. Melina Ballario December 10, 2020 at 11:08 am - Reply

    how terrible music behind! impossible to follow the lesson

  12. sudha devi December 10, 2020 at 11:08 am - Reply

    I like the way you explain…simply superb!!!

  13. Leōn December 10, 2020 at 11:08 am - Reply

    watch at 2x speed

  14. Harshal Shedolkar December 10, 2020 at 11:08 am - Reply

    Hey, can we use multi-threading to speed up our prediction through model? If that's possible, can you tell how to do that?

  15. Sameer uddin December 10, 2020 at 11:08 am - Reply

    Sir I did the same thing in which i am searching a specific word in the files of two different folders named "folder1" and "folder2".I make two threads and in each thread passing both functions find_text1() in "thread1" and find_text2() in "thread 2" both functions search the word in their respectiv folders . But there is no time difference between normal execution and with multi threading.

    Kindly guide me why their is no time difference …

  16. Jordan Greenhut December 10, 2020 at 11:08 am - Reply

    I like the busy mom analogy. I can't even multi task in real life fr

  17. Sawani Soman December 10, 2020 at 11:08 am - Reply

    Great tutorial. Thank you so much

  18. OttoNL December 10, 2020 at 11:08 am - Reply

    Thank you! Great explanation, easy to follow. This will help my little project a lot!

  19. Nabeel Ahmad December 10, 2020 at 11:08 am - Reply

    can we create multiple threds in one class

  20. Fiona Tsang December 10, 2020 at 11:08 am - Reply

    Great explanation. This is so clear. Thanks so much!

    I love how you used "busy mom" as the non-coding example which made everything afterward so easy to digest. I initially did not follow what join() meant til I stuck til the end of the video after you provided a diagram with it 🙂

    Everywhere else on the Internet has not done a good job of explaining JOIN(), but you did! 🙂

  21. Borat Sagdiyev December 10, 2020 at 11:08 am - Reply

    codebasics, everyone loves you this is awesome.

  22. John Ortiz Ordoñez December 10, 2020 at 11:08 am - Reply

    Thanks for sharing! Good video!

  23. Alexander Desroches December 10, 2020 at 11:08 am - Reply

    Very good but please no music.

  24. Ullash Podder December 10, 2020 at 11:08 am - Reply

    anyone thinking about the return value of the function, it seems easiest way is either introducing Queue or using Threadpool!

  25. Deven D December 10, 2020 at 11:08 am - Reply

    I don't agree with the analogy between mom's tasks and multi-threading, there is a subtle difference. Multi-threading is not really parallel execution of tasks.

    In the video, each function runs only when the other is waiting, so it not true parallelism. It is called concurrency in programming terminology and is different from parallelism.

    In the example from the video, the mom's tasks are truly "parallel" because she juggles multiple tasks without any wait in between. They are the equivalent of multi-processing and not multi-threading.

    Finally, the example in the video is not a good use case for multi-threading because the total run time is only increased by including threading and wait times. Multi threading is good for scenarios where I/O is the bottleneck – for example, multiple web requests.

  26. karthik 909 December 10, 2020 at 11:08 am - Reply

    skip to 1:49 for the content

  27. LawlietNao December 10, 2020 at 11:08 am - Reply

    hey this is amazing! I actually learned something from this while having the chill acoustic music playing. It really makes it less frustrating. Thank you my dude.

  28. Peyton Blanscet December 10, 2020 at 11:08 am - Reply

    Bruh I've always hated python but it's a very useful language so I've been forcing myself to learn it. You are absolutely the most clear and concise way I've found so far to explain it. Now I understand it and can actually use it, instead of just having code to copy and paste

  29. Swadhikar C December 10, 2020 at 11:08 am - Reply

    Concepts are well explained but the example looks noob

  30. Mehdi Hachimi December 10, 2020 at 11:08 am - Reply

    Amazing explanation thank you !!

  31. BINUKITTOOP December 10, 2020 at 11:08 am - Reply

    This is first time that I am seeing the concept of Multi-threading is explained in such a simple way… Great work dude…! Keep on going…!

  32. Amit Nikhade December 10, 2020 at 11:08 am - Reply

    how to stop a thread from a function

  33. josy26 December 10, 2020 at 11:08 am - Reply

    Great stuff, but why the music?

  34. Luccas Zulliane December 10, 2020 at 11:08 am - Reply

    Thanks, man, indeed really good tutorial!

  35. Arjun Umathanu December 10, 2020 at 11:08 am - Reply

    [x**2 for x in (1,2,3,4,5,6,7,8,9)] ; [x**3 for x in (1,2,3,4,5,6,7,8,9)] # 😀

  36. Satyam Mandal December 10, 2020 at 11:08 am - Reply

    In threading why we use ".join" method

  37. Satyam Mandal December 10, 2020 at 11:08 am - Reply

    in threading why use join method

  38. Abhishek Gautam December 10, 2020 at 11:08 am - Reply

    why we use time.time()-t..?

  39. Skofta December 10, 2020 at 11:08 am - Reply

    Thank you!

  40. Mack Black December 10, 2020 at 11:08 am - Reply

    Thank u so much India

  41. Hitesh Agashe December 10, 2020 at 11:08 am - Reply

    Can we perform multithreading on two different python (.py) files?? If Yes then How…??? Kindly reply ASAP…

  42. SY Tan December 10, 2020 at 11:08 am - Reply

    Great tutorial.

  43. Tri Nanda December 10, 2020 at 11:08 am - Reply

    Thanks..

  44. 王瑞世 December 10, 2020 at 11:08 am - Reply

    Thanks your videos Helped me
    python requests http://bit.ly/2PPPr0p

  45. Arno Jones December 10, 2020 at 11:08 am - Reply

    That was a great introduction for me. Simple and clear. I watched other examples before this one and I left more confused. I'm half deaf, too, so I appreciated the lower music volume, too (one symptom of partial deafness is the inability to separate background from foreground sounds of equal volume)

  46. kumropotashify December 10, 2020 at 11:08 am - Reply

    Very good tutorials!

  47. Holly Peck December 10, 2020 at 11:08 am - Reply

    "mom is doing multi-threading"

  48. Iván O. December 10, 2020 at 11:08 am - Reply

    Absolutely great explanation and useful material. THANKS A LOT!

Leave A Comment

*