Learn Python MULTITHREADING in 8 minutes! 🧵

  Рет қаралды 6,502

Bro Code

Bro Code

Күн бұрын

#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):
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 = threading.Thread(target=take_out_trash)
chore2.start()
chore3 = threading.Thread(target=get_mail)
chore3.start()
.join() ensures that all tasks are completed before proceeding
chore1.join()
chore2.join()
chore3.join()
print("All chores are complete!")

Пікірлер: 23
Learn Python OOP in under 20 Minutes
18:32
Indently
Рет қаралды 32 М.
threading vs multiprocessing in python
22:31
Dave's Space
Рет қаралды 580 М.
So Cute 🥰
00:17
dednahype
Рет қаралды 58 МЛН
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 40 МЛН
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 47 МЛН
Let's code a beginner's Python BANK PROGRAM 💰
15:01
Bro Code
Рет қаралды 166 М.
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
How I Would Learn Python FAST in 2024 (if I could start over)
12:19
Thu Vu data analytics
Рет қаралды 322 М.
All 39 Python Keywords Explained
34:08
Indently
Рет қаралды 176 М.
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 146 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,2 МЛН
Learn Python in 1 hour! 🐍 (2024)
1:00:00
Bro Code
Рет қаралды 72 М.
Python As Fast as Possible - Learn Python in ~75 Minutes
1:19:41
Tech With Tim
Рет қаралды 1,8 МЛН
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 171 М.
So Cute 🥰
00:17
dednahype
Рет қаралды 58 МЛН