This commit is contained in:
jon ander 2024-11-14 19:02:52 +01:00
parent 3d19f91ee8
commit c9da9ce60e
7 changed files with 75 additions and 0 deletions

7
.idea/discord.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="APPLICATION" />
<option name="description" value="" />
</component>
</project>

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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()