Learn Python MULTITHREADING in 8 minutes! 🧵

preview_player
Показать описание
#python #pythonprogramming #pythontutorial

# multithreading = Used to perform multiple tasks concurrently (multitasking)
# Good for I/O bound tasks like reading files or fetching data from APIs

import threading
import time

def walk_dog(first, last):
print(f"You finish walking {first} {last}")

def take_out_trash():
print("You take out the trash")

def get_mail():
print("You get the mail")

chore1 = threading.Thread(target=walk_dog, args=("Scooby", "Doo"))

chore2 = threading.Thread(target=take_out_trash)

chore3 = threading.Thread(target=get_mail)

# .join() ensures that all tasks are completed before proceeding

print("All chores are complete!")
Рекомендации по теме
Комментарии
Автор

# multithreading = Used to perform multiple tasks concurrently (multitasking)
# Good for I/O bound tasks like reading files or fetching data from APIs

import threading
import time

def walk_dog(first, last):
time.sleep(8)
print(f"You finish walking {first} {last}")

def take_out_trash():
time.sleep(2)
print("You take out the trash")

def get_mail():
time.sleep(4)
print("You get the mail")

chore1 = threading.Thread(target=walk_dog, args=("Scooby", "Doo"))
chore1.start()

chore2 =
chore2.start()

chore3 =
chore3.start()

# .join() ensures that all tasks are completed before proceeding
chore1.join()
chore2.join()
chore3.join()

print("All chores are complete!")

BroCodez
Автор

bro taught me in 8 minutes what a year of school could not 🗿

mxfze
Автор

Almost at 2 Million! 🎉 I have watched your HTML/CSS course and I learned in about 4 days. I am now making websites for people and they are amazed by them. I am also learning C++ and it is going well because of you. Thank you for opening up this possible future for me and making my dreams come true! Thank you Bro!

lucidd_
Автор

hello chad,
please make tutorials on data structure and algorithms in c++,

wyr
Автор

Great Bro.
It would be great help if you could make a tutorial on regular expression as well.

animetime
Автор

Thanks a lot ...can you also make a tutorial on python asynchronous programming

robert-qnhy
Автор

Bro can you please use ui with a pop out color to see clearly

layfonkolar
Автор

I always wondered Y can't I just pass args
Turns out it needs to be represented as tuple

Thanks now I don't need to create wrapper functions, 🙃🙃

Un_revealing
Автор

I'm very interested if you could make an AI course 😊😇

TechTalk
Автор

Bro can you please a make video on python daemon threads please...

robert-qnhy
Автор

Hey man I have a question I am 20 years old I feel like I would be going in way to late into the industry of engineering so would like some advice if you could, if you were to restart how would you do it with todays economy would you still look for a bootcamp and go with that or go a different route, like for me I was thinking I could go to college for 2 years as an engineer which would be an associates just to build the resume and after that go into a bootcamp

angelnoyola
Автор

i get error of no attribute 'Thread'(most likely due to a circular import) any help?

YoruAmeHD