47. Sleep Function and Multithreading in Python with Code || Time Module Programming Tutorial

Publicado em: 16 Agosto 2022
no canal de: Bhavatavi
102
0

The sleep() function suspends (waits) execution of the current thread for a given number of seconds.
Multithreading in Python enables CPUs to run different parts(threads) of a process concurrently to maximize CPU utilization.

Code:

import time
while True:
localtime=time.localtime()
result=time.strftime("%I:%M:%S %p",localtime)
print(result)
time.sleep(1)

import threading

def print_hello():
for i in range(3):
time.sleep(0.7)
print("Hello")

def print_hi():
for i in range(3):
time.sleep(0.9)
print("Hi")

t1=threading.Thread(target=print_hello)
t2=threading.Thread(target=print_hi)

t1.start()
t2.start()


Nesta página do site você pode assistir ao vídeo on-line 47. Sleep Function and Multithreading in Python with Code || Time Module Programming Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Bhavatavi 16 Agosto 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 102 vezes e gostou 0 espectadores. Boa visualização!