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

Pubblicato il: 16 agosto 2022
sul canale di: 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()


In questa pagina del sito puoi guardare il video online 47. Sleep Function and Multithreading in Python with Code || Time Module Programming Tutorial della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Bhavatavi 16 agosto 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 102 volte e gli è piaciuto 0 spettatori. Buona visione!