This commit is contained in:
jon ander 2024-11-09 19:09:12 +01:00
parent a09ce39ac6
commit 3d19f91ee8
6 changed files with 42 additions and 35 deletions

View File

@ -1,13 +0,0 @@
import threading
def escribeY():
for i in range(1000):
print ("y", end="",flush=True)
return
print ("INICIO")
t = threading.Thread(target=escribeY)
t.start()
for i in range(1000):
print ("X", end="",flush=True)

View File

@ -1,8 +0,0 @@
import threading
def Saludo():
print ("hola,soy el hilo\n")
t = threading.Thread(target=Saludo)
t.start()
print("Hola soy el hilo principal")

View File

@ -1,13 +0,0 @@
import threading
def escribeY():
for i in range(1000):
print ("y", end="",flush=True)
return
print ("INICIO")
t = threading.Thread(target=escribeY)
t.start()
for i in range(1000):
print ("X", end="",flush=True)

View File

@ -0,0 +1,17 @@
import threading
import time
def escribeY():
for i in range(100):
print (".", end="",flush=False)
time.sleep(1)
return
print ("INICIO")
t = threading.Thread(target=escribeY)
t.start()
for i in range(50):
print ("-", end="",flush=False)
time.sleep(2)

View File

@ -0,0 +1,25 @@
import threading
import time
import random
def tareaUno():
global Done
time.sleep (random.random())
if not Done:
print("Tarea realizada")
time.sleep(0.12)
Done = True
else :
print ("tarea NO REALIZADA")
time.sleep(0.05)
return
Done = False
hilos = list()
for i in range(50):
t = threading.Thread(target=tareaUno)
hilos.append(t)
t.start()
tareaUno()
time.sleep(1)

View File

@ -1 +0,0 @@
test