aula de thread

This commit is contained in:
Fernando Luiz de Lima
2026-04-17 21:46:48 -03:00
parent 401c336ba6
commit e0ccfdf7d8
5 changed files with 97 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import threading
import time
# Função que será executada pela thread
def executar(nome_thread, n_iteracoes):
for i in range(n_iteracoes):
print(f"nome da thread: {nome_thread}")
time.sleep(2) #Parar por 2s
t1 = threading.Thread(target=executar,args=["thread1",15,])
t2 = threading.Thread(target=executar,args=["thread2",10,])
t1.start()
t2.start()
t1.join
t2.join
print("final da thread principal")