diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..a98cb47 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/ejemplos/paralelismo01/ej01.py b/ejemplos/paralelismo01/ej01.py new file mode 100644 index 0000000..df063f9 --- /dev/null +++ b/ejemplos/paralelismo01/ej01.py @@ -0,0 +1,13 @@ +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) \ No newline at end of file diff --git a/ejemplos/paralelismo01/ej02.py b/ejemplos/paralelismo01/ej02.py new file mode 100644 index 0000000..107659e --- /dev/null +++ b/ejemplos/paralelismo01/ej02.py @@ -0,0 +1,17 @@ +import threading +import time +import random + +def tareaUno(): + global Realizado + #time.sleep (random.random()) + if not Realizado: + print("Tarea realizada") + Realizado = True + return + +Realizado = False +t = threading.Thread(target=tareaUno) +t.start() +tareaUno() +time.sleep(1) \ No newline at end of file diff --git a/ejemplos/paralelismo01/ej03.py b/ejemplos/paralelismo01/ej03.py new file mode 100644 index 0000000..a77d295 --- /dev/null +++ b/ejemplos/paralelismo01/ej03.py @@ -0,0 +1,23 @@ +import threading +import time +import random + +def tareaUno(): + global Done + time.sleep (random.random()) + if not Done: + print("Tarea realizada") + Done = True + else : + print ("tarea NO REALIZADA") + return + +Done = False +hilos = list() +for i in range(50): + t = threading.Thread(target=tareaUno) + hilos.append(t) + t.start() + +tareaUno() +time.sleep(1) \ No newline at end of file diff --git a/ejemplos/paralelismo01/Ej03-thread.py b/ejemplos/paralelismo01/ej04.py similarity index 100% rename from ejemplos/paralelismo01/Ej03-thread.py rename to ejemplos/paralelismo01/ej04.py diff --git a/ejemplos/paralelismo02/ej01.py b/ejemplos/paralelismo02/ej01.py new file mode 100644 index 0000000..6ac6530 --- /dev/null +++ b/ejemplos/paralelismo02/ej01.py @@ -0,0 +1,15 @@ +import logging +import threading +import time + +def thread_Apellido(name, inicio=1, fin=1): + for x in range(inicio, fin): + print (f"{name} Rodríguez {str(x)} años\n",end="") + + +nombres = ["Julio", "Javier", "Eladio", "Jose", "Manuel"] +hilos = list() +for n in nombres: + t = threading.Thread(target=thread_Apellido, args=(n,), kwargs={'inicio':5, 'fin':8}) + hilos.append(t) + t.start() \ No newline at end of file diff --git a/ejemplos/paralelismo01/Ej02-thread.py b/ejercicios/paralelistmo01/Ej02-thread.py similarity index 100% rename from ejemplos/paralelismo01/Ej02-thread.py rename to ejercicios/paralelistmo01/Ej02-thread.py