You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
413 B

import threading
import time
def tarea(num):
for _ in range (num):
print("Ejecutando tarea...")
time.sleep(1)
#print (threading.currentThread().name)
veces = 10
t = threading.Timer(3, tarea, [veces,])
print("Iniciando hilo con temporizador")
t.start() #será ejecutado tras tres segundos
time.sleep(5)
#prueba para cancelar el hilo
print("Cancelando la tarea <<si no se ha comenzado>>")
t.cancel()

Powered by Informatica FP.