Threading Tutorial #2 - Implementing Threading in Python 3 (Examples)

  Рет қаралды 152,434

Tech With Tim

Tech With Tim

Күн бұрын

This threading tutorial discusses how to use the threading module in python 3 and goes over some examples of using multiple threads. The python version used in this video is python 3.8 and threading is implemented with the newest version of the threading module.
Playlist Link: • Threading Tutorial #1 ...
◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python
tech-with-tim....
📸 Instagram: / tech_with_tim
🌎 Website techwithtim.net
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-ruscica-82631b179
📂 GitHub: github.com/tec...
🔊 Podcast: anchor.fm/tech...
💵 One-Time Donations: www.paypal.com...
💰 Patreon: / techwithtim
◾◾◾◾◾◾
⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
⭐ Tags ⭐
- Tech With Tim
- Python Tutorials
- Python 3 Threading
- Threading Python
- Thread Tutorial Python
- Threading Module Python
⭐ Hashtags ⭐
#Python #Threading #Concurrency

Пікірлер: 166
@TechWithTim
@TechWithTim 4 жыл бұрын
Had some audio issues with the previous upload but seems to be working now! Let me know if there any other *bugs* in the video!
@akshatsingh7286
@akshatsingh7286 4 жыл бұрын
Yea Ik it said Private vid. Love you btw!! Please make a ML from basics video
@SkyFly19853
@SkyFly19853 4 жыл бұрын
Oh, I was wondering about that... That's OK as long as this video works.
@dwarkeshhaldankar2612
@dwarkeshhaldankar2612 4 жыл бұрын
Make the next video in this series. I wanna learn more!!
@3ngineer427
@3ngineer427 3 жыл бұрын
you said you'll cover the global memory accessing, fixing the issue with block @10:20 but the new video didn't show up? Maybe it's because you're too busy, but it might be helpful if you forgot the put a new video for this one :) BTW, you're an awesome teacher so far bro!!
@AbhishekSingh-du5di
@AbhishekSingh-du5di 3 жыл бұрын
Oh my god, You saved my project thanks a lot! Stay blessed tim
@dguiles1
@dguiles1 2 жыл бұрын
Dude Tim. You literally taught me threading in python in ten minutes, flawlessly. I am extremely humbled by your thorough understanding and willingness to teach others. Thank you! Your videos are literal gold for autodidactic individuals.
@LuisPereira-bn8jq
@LuisPereira-bn8jq 4 жыл бұрын
Awesome video. I wanted to implement a little threading in a mini project for webscrapping definitions from an online dictionary and this quickly taught me 80% of what I needed.
@milanpaudel9624
@milanpaudel9624 4 жыл бұрын
Sound quality is awesome and loud. I'm glad you sort it out. Always supporting you forever.
@TechWithTim
@TechWithTim 4 жыл бұрын
:)
@alank1995
@alank1995 2 жыл бұрын
You have a way of making things simple and easy to digest. I watched a few other videos before yours and left with more confusion than when I started. Half way through your video it all clicked. Thanks for the help!!!
@javiarroyo8358
@javiarroyo8358 4 жыл бұрын
i have been struggling with thread for weeks till u suddenly decided to do this tutorial, tyvm bro, u are really helping me to truly understand how python and coding works
@ohwow2074
@ohwow2074 4 жыл бұрын
maaan your explanations are awesome!!! Never seen a simple explanation like this
@numberiforgot
@numberiforgot 3 жыл бұрын
I wish I had discovered your channel back when I first started programming. Would have saved me months. You talk and instruct just like a college level professor. Easy to understand and you don't digress at all.
@utpalmohane1416
@utpalmohane1416 2 жыл бұрын
Lately I watch and practice practically on my computer along with your video and this has helped me a lot. Your explanation was mind- boggling and your speech is clear. Thanks and keep up the great work.
@willraasch7816
@willraasch7816 2 жыл бұрын
This was the answer to my biggest problem in my program, Thank you!
@ak.pod31
@ak.pod31 4 жыл бұрын
Could you do multiprocessing as well after threading? Thank you!
@oldmankatan7383
@oldmankatan7383 3 жыл бұрын
For anyone else who finds this, the short answer is yes. The long answer is, you (usually) want to do your multiprocessing from __main__, and then if any of those processes require threading do the threading inside of that process. This is mostly due to the ways you get data out of threads (same process same heap) vs. processes (different process, different heap).
@smartlearnteam
@smartlearnteam 2 жыл бұрын
Thanks a lot, Tim. I've been trying to understand this concept so many times without succeding. Your explanation here together with the theoretical basis given in the previous part gave me a clear picture of how this works and how to implement it in my code. Thanks again, you have a great channel.
@we_super_dooper
@we_super_dooper 2 жыл бұрын
great explantaion 👍👍👍
@mhho2336
@mhho2336 Жыл бұрын
Dude, your tutorial is awsome
@dnetne5508
@dnetne5508 4 жыл бұрын
Wow.. I actually did not think you could explain things this well, not only in this video, but also in the last one... Big thanks from the heart!
@RobertWei-p1l
@RobertWei-p1l Жыл бұрын
Thank you Tim!! Really helpful
@junaidmahmud2894
@junaidmahmud2894 2 жыл бұрын
It was a delight watching this tutorial. Nicely explained with a great sequence!
@quickdry3
@quickdry3 4 жыл бұрын
I know this might not be appropriate for the target audience, but a good explanation of the GIL, and what that means for threading in particular might be helpful to people expecting more parallel execution of their code (and why async approaches or multiprocessing might be more suitable).
@КабаневичКабанян
@КабаневичКабанян 4 жыл бұрын
Thank you! Very well explained! Understood you much better than literature on my native language
@rahultiwari55
@rahultiwari55 3 жыл бұрын
I noticed that you somehow missed to use function count2 in the flow. That's why it got confusing.
@CodePhiles
@CodePhiles 4 жыл бұрын
great demonstration, Thanks , I would always use print from each thread to make it clear for me, like in thread #1 , you could print "I am coming from Thread #1" and for thread #2 , you could print "I am coming from Thread #2" and so on
@frozen7535
@frozen7535 3 жыл бұрын
Perfect vid, tim gave the explanation plus the examples i needed
@San_desh24
@San_desh24 3 жыл бұрын
Bravo!! Ut theoretical and practical makes a lot clear
@akashkumarjain654
@akashkumarjain654 4 жыл бұрын
I am really thankful to you Sir for these informative videos on channel.
@joshuakoehler6457
@joshuakoehler6457 3 жыл бұрын
Is there a third video coming out for this? I don't see it in the playlist...
@Chaosman88
@Chaosman88 3 жыл бұрын
I guess the third part never came.. Would be good though.
@BT-kf4kx
@BT-kf4kx 2 жыл бұрын
There will be lots more coming I hope 🤞
@OmerMeshy
@OmerMeshy 3 жыл бұрын
Thank you very much! That video help me to solve a big problem in my code
@ophelia6207
@ophelia6207 3 жыл бұрын
Thanks so much, you're making it so easy to understand
@yashpundir2044
@yashpundir2044 3 жыл бұрын
Just amazing... please bring out the next video soon.
@satanthegamer3969
@satanthegamer3969 3 жыл бұрын
really wish there were more of these!
@haaziquesayyed5473
@haaziquesayyed5473 3 жыл бұрын
hey pls continue this series
@GreenfieldPortfolioResearch
@GreenfieldPortfolioResearch Жыл бұрын
excellent content! straight to the point. enormously useful.
@venkatv4993
@venkatv4993 3 жыл бұрын
superb explanation understood something with this video after watching n number of other videos Great Tech with Tim always explains well in detail. thanks for teaching us
@mbonuchinedu2420
@mbonuchinedu2420 4 жыл бұрын
Your coding is swift. Thanks Tim🥰💥💥💥
@MiloLabradoodle
@MiloLabradoodle 3 жыл бұрын
Very nice presentation on this topic. Thanks so much.
@ue5dev617
@ue5dev617 4 жыл бұрын
Very very interesting ! Thanks so much for your explanation, you made it crystal clear. Please continue on this serie as much as you can (and also multiprocessing if possible) You're amazing ! Keep up the good work !
@CodingWithFelipe
@CodingWithFelipe 28 күн бұрын
Great video!
@davibus
@davibus 2 жыл бұрын
Great stuff. Thanks!
@SandipPoddar
@SandipPoddar 4 жыл бұрын
Good work Tim, keep it up. Supporting you forever, learnt a lot from you and expecting much more videos from you. Nice explanation and example. Motivated me a lot. Want more and more "Expert Python Tutorial" and Threading videos. Lots of love from INDIA.
@edzme
@edzme 3 жыл бұрын
Tim - you're a great teacher, love how you explain stuff and really break it down. 👍👍👍👍
@staticbits
@staticbits 4 жыл бұрын
Can't wait for the next video!
@donaldhu2392
@donaldhu2392 3 жыл бұрын
Your video is Super Awesome!!! Thank you!!
@relaxingwithmidfulmoment1177
@relaxingwithmidfulmoment1177 2 жыл бұрын
Tim how to pause and resume a thread ? Thanks man
@karlchristiaens4673
@karlchristiaens4673 Жыл бұрын
Amazing! thank you
@qazqaz2912
@qazqaz2912 4 жыл бұрын
Wanna push like button but four 6 in a row under this video don't let me do it :)) p.s. Amazing video! Big thanks!
@richardravich8337
@richardravich8337 4 жыл бұрын
Great tutorial, Tim and I'm looking forward to the next one in the series. BTW, I noticed that you use both " and ' for strings. Shouldn't a programmer standardize on one? I know they are equivalent, but just for ease, shouldn't you standardize on one? Just curious...
@ikbenmathijs9424
@ikbenmathijs9424 4 жыл бұрын
I didn't even notice lol
@IND_Abhi
@IND_Abhi 4 жыл бұрын
which keyboard do you use?
@Aadyagupta5679
@Aadyagupta5679 4 жыл бұрын
please cover all topic related to multiprocessing and multithreading
@F_M_911
@F_M_911 2 жыл бұрын
thank you very much💗
@TahaCodes
@TahaCodes 4 жыл бұрын
Hey Tim, thanks for the great tutorial.
@HuyNguyen-fp7oz
@HuyNguyen-fp7oz 4 жыл бұрын
first! After 3 try, finally got it.
@TechWithTim
@TechWithTim 4 жыл бұрын
Yep! Finally lol
@HuyNguyen-fp7oz
@HuyNguyen-fp7oz 4 жыл бұрын
@@TechWithTim Keep good work, Tim. I learn alot from your videos!
@noahnolte7288
@noahnolte7288 4 жыл бұрын
Very helpful! Thanks!
@link9645
@link9645 4 жыл бұрын
Thanks for the tutorial all could you possibly go over multithreaded socket programming later on in the series?
@bechararizk7245
@bechararizk7245 4 жыл бұрын
hey just asking when will the next video about threading come out? thanks a lot for doing these tutorials
@Dsuchong
@Dsuchong 2 жыл бұрын
well done!
@lightblue6746
@lightblue6746 4 жыл бұрын
11:25 Both of your threads(x and y) are targeted to function count. Is this what you meant or was it your fault??
@ronen124
@ronen124 2 жыл бұрын
you are the best
@jakubcaputa9265
@jakubcaputa9265 4 жыл бұрын
11:42 You can try time.sleep(5) you sleep the main thread for 5 seconds and then you get desired output.
@adamgy
@adamgy 4 жыл бұрын
You could get away with that here, but in practical scenarios you won't know how much time the other threads take, so it's better to use join.
@arpitdiwan4573
@arpitdiwan4573 4 жыл бұрын
thanks you
@TopBagon
@TopBagon 4 жыл бұрын
Nice one. Thanks a lot
@hasibislam4421
@hasibislam4421 3 жыл бұрын
AttributeError: partially initialized module 'threading' has no attribute 'Thread' (most likely due to a circular import).....What does this mean?
@oyoplayer
@oyoplayer 3 жыл бұрын
Thank !
@houssamhoussam2919
@houssamhoussam2919 4 жыл бұрын
thank you sir for you video very good waiting for new video :)
@psharma2067
@psharma2067 4 жыл бұрын
Perfect
@eddyhe
@eddyhe 8 ай бұрын
In the example, do the threads stop running after ls is printed? or do the threads continue to run after the print, but we want to see the ls with all of the elements appended to it so we have the .joins
@archibaldaddelton4432
@archibaldaddelton4432 4 жыл бұрын
in somenext tutorial I hope you get to using variable of thread "x" inside thread "y"
@danieleperera6788
@danieleperera6788 4 жыл бұрын
Nice video! Keep up the good work! Do you mind doing some complicated examples where you use queues. Maybe a project like scraping the web to collect news feeds... something like that. With a real world example. Thanks a lot! Have a good one
@__3093
@__3093 3 жыл бұрын
your mic has gone crazy in this video
@MrWaimanu
@MrWaimanu 2 жыл бұрын
Hi Tim. Really enjoying the tutorials. Would it be possible for a new threading video that covers the type of actions a function might do that would cause the cpu to switch threads? In the example you have time.sleep(), but in practise I'm unsure what other types of functions/actions would result in the program jumping between threads.
@parallel2death541
@parallel2death541 2 жыл бұрын
while trying to import threading i keep getting a Not Implemented Error. How do i fix this?
@sprototles
@sprototles 2 жыл бұрын
Moooore !!!!
@bradenbigham2487
@bradenbigham2487 2 жыл бұрын
using multithreading to create a random number generator.
@ganjarulez009
@ganjarulez009 Жыл бұрын
You had target=count in both threads, so the count2 function is pretty much useless no?
@jmsolorzano13
@jmsolorzano13 Жыл бұрын
Hi Tim! Excellent video... I can development an ashyncronate Application. But when I deploy in my docker container... not working.. :( Do you Know, if I need some special config to docker flask app with threading?
@tjpeterson44
@tjpeterson44 4 жыл бұрын
Excellent guide Tim! Just one question, how do you return a value from a thread and use it in the main thread?
@MohamedHassan-zi7ms
@MohamedHassan-zi7ms 2 жыл бұрын
Greeeaaaaaaaaaaaaat :)
@krishj8011
@krishj8011 4 жыл бұрын
awesome....
@azurnxo2134
@azurnxo2134 4 жыл бұрын
Tim, What is your main programming language? I'm about to start with my first programming language, although I know python. What should I really start with? Please enlighten me. Thanks in advance.
@007MrNiko
@007MrNiko 4 жыл бұрын
Same question... @Tim
@feliperocha6521
@feliperocha6521 4 жыл бұрын
"I'm about to start with my first programming language, although I know python" I wonder what you think python is. Not gonna lie, it actually got me laughing.
@azurnxo2134
@azurnxo2134 4 жыл бұрын
@@feliperocha6521 bruhh
@azurnxo2134
@azurnxo2134 4 жыл бұрын
@@feliperocha6521 python is like a spoon fed to the software devs. I know it's amazing, but it's laughable at the same time. You need to know a deeper programming language to become more aware of your machine. For example, C++ makes you really aware of your machine and it's operations. Java, on the other hand derives its traits from C++, but it still is not as powerful as C++. C#, one of best programming languages out there, gets you covered in every aspect of software developing.
@VerifyBot
@VerifyBot 4 жыл бұрын
@@azurnxo2134 i disagree.
@beingraja9586
@beingraja9586 4 жыл бұрын
Good plZ try neural nets
@TheEbbemonster
@TheEbbemonster 4 жыл бұрын
Any part 3 in the pipeline? I have been doing to threading in a project, but ended up having trouble saving the outputs, as they wrote over each other :(
@domasvaitmonas8814
@domasvaitmonas8814 3 жыл бұрын
Amazing. Thanks a lot! I hope you can produce another vid on multithreading. Loved this one. By the way -- I wanted to donate to you via Brave browser, but couldn't. If you register, I could donate ;)
@ue5dev617
@ue5dev617 4 жыл бұрын
Will you talk about Semaphores ?
@vishalwaghmare3130
@vishalwaghmare3130 2 жыл бұрын
What was this 12:58 ? I started looking around me..!
@dmbrv
@dmbrv 4 жыл бұрын
nice video
@PGhai
@PGhai 3 жыл бұрын
What is the logic of using _ in for loop? Could you plz explain or share some reference link?
@hosseinzakariaee5465
@hosseinzakariaee5465 3 жыл бұрын
hi tim i have qustion what is your ide
@bvg129
@bvg129 4 жыл бұрын
Why you never use autocomplete?
@cuthbertmilligen
@cuthbertmilligen 3 жыл бұрын
I think you probably wanted the y-thread to use count2. But as count and count2 are identical it makes no difference. So why create count2?
@codeKeshav
@codeKeshav 3 жыл бұрын
How your sublime text editor gives preference of keywords. Would you tell the settings
@EK-ck2xf
@EK-ck2xf 4 жыл бұрын
Are you sure print('ran') will be executed as you've predicted? Isn't It possible that the last line in the code will be executed before? What does the python specification tells about running threads concurrently?
@peterkim9696
@peterkim9696 Жыл бұрын
please help I have a txt file the contains urls to scrape something in each url and print result but whenever I add threads i see that requests prints duplicate results how can I solve that
@bartek9167
@bartek9167 4 жыл бұрын
How do you spawn new thread without assigning variable to it? (Or automatically assigning variable)
@Thiagola92
@Thiagola92 3 жыл бұрын
2:40 That is incorrect (5,) and (5, None) are not the same The second will have None as second value, the first will be a tuple with only the first value
@panzorax.
@panzorax. 4 жыл бұрын
Hi bro I have question this threads how can use in pyqt5 when I click button ?? Can you show us a example?
@julesuntalan9159
@julesuntalan9159 4 жыл бұрын
Hi, I'm new to python and currently learning from scratch. I have this project to automate a system using webdriver & selenium and at the same time, I need to create a screen recording using cv2. My problem is when I apply this threading, the flow of my code is that once automation was done it will execute the screen recording in which I need to do this at the same time. Hope you can help me with this project. Thank you!
@yeasinhossain8234
@yeasinhossain8234 2 жыл бұрын
Pleae can anyone tell me that, How can I solve the repeat problem like 1,1,2,2,3,3.. Am trying to create a Bruteforce tool and it’s still Doing the same password multiple times? Any solution?
@muni3131
@muni3131 3 жыл бұрын
Thank. I’m wondering if multitasking will solve a problem I have but so far I can’t see a solution. Briefly, I have a window on which a function is running and it’s changing a lot of data on that screen. Then there is a pause button that needs to pause the process. I believe it must be possible; surely it’s normal to have start, stop, pause buttons on a window, but threads don’t seem to be allowed to interact with the same window especially were one thread is doing a lot of window updating. Does that make sense or am I barking up the wrong tree?
@jayeshkawli
@jayeshkawli 3 жыл бұрын
Is there any way to view all the running threads in Pycharm?
@__epicgaming__3492
@__epicgaming__3492 3 жыл бұрын
4:20 For me it prints the number first, and then "ran", and "done"
@manaspaul
@manaspaul 4 жыл бұрын
I am getitng ran3 >>> Done
@premgarg5534
@premgarg5534 4 жыл бұрын
Hi, i have a query I want a python script to run at boot time but not the whole program just one thread, SO can anyone please help me it that
Python Asynchronous Programming - AsyncIO & Async/Await
25:57
Tech With Tim
Рет қаралды 427 М.
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 54 МЛН
Шок. Никокадо Авокадо похудел на 110 кг
00:44
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 54 МЛН
HAH Chaos in the Bathroom 🚽✨ Smart Tools for the Throne 😜
00:49
123 GO! Kevin
Рет қаралды 15 МЛН
Python Tutorial: if __name__ == '__main__'
8:43
Corey Schafer
Рет қаралды 2 МЛН
threading vs multiprocessing in python
22:31
Dave's Space
Рет қаралды 581 М.
Python Socket Programming Tutorial
49:43
Tech With Tim
Рет қаралды 1 МЛН
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 163 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 308 М.
Unlocking your CPU cores in Python (multiprocessing)
12:16
mCoding
Рет қаралды 304 М.
Expert Python Tutorial #6 - Context Managers
16:38
Tech With Tim
Рет қаралды 70 М.
Python multithreading 🧵
13:34
Bro Code
Рет қаралды 65 М.
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 113 М.
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 54 МЛН