mirror of https://github.com/JavMB/ejercicios
02.py
This commit is contained in:
parent
bfb9b6b773
commit
f7486171bc
|
|
@ -1,15 +1,26 @@
|
||||||
import threading
|
import threading
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
|
||||||
|
def hilo1():
|
||||||
|
time.sleep(random.uniform(0, 1.5))
|
||||||
|
print("Soy el Hilo 1 y primero")
|
||||||
|
|
||||||
def Hilo2():
|
def hilo2():
|
||||||
print ('Soy el hilo 2\n')
|
time.sleep(random.uniform(0, 1.5))
|
||||||
t3 = threading.Thread(target=Hilo3)
|
print("Soy el hilo 2")
|
||||||
t3.start()
|
|
||||||
|
|
||||||
def Hilo3():
|
def hilo3():
|
||||||
print ('Soy el hilo 3 y último\n')
|
time.sleep(random.uniform(0, 1.5))
|
||||||
|
print("Soy el hilo 3 y último")
|
||||||
t2 = threading.Thread(target=Hilo2)
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
t1 = threading.Thread(target=hilo1)
|
||||||
|
t2 = threading.Thread(target=hilo2)
|
||||||
|
t3 = threading.Thread(target=hilo3)
|
||||||
|
t1.start()
|
||||||
t2.start()
|
t2.start()
|
||||||
print ("Soy el Hilo 1 y primero\n")
|
t3.start()
|
||||||
|
t1.join()
|
||||||
|
t2.join()
|
||||||
|
t3.join()
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
import threading
|
||||||
|
|
||||||
|
def escribeY():
|
||||||
|
for i in range(1000):
|
||||||
|
print (".", end="",flush=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
print ("INICIO")
|
||||||
|
t = threading.Thread(target=escribeY)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
for i in range(1000):
|
||||||
|
print ("-", end="",flush=True)
|
||||||
Loading…
Reference in New Issue