Compléter Sistemas Operativos Semana 4 Act 2Version en ligne Estructura de Datos Semana 1 par Anyelo Gerley Quintero Reyes 1 join start sleep hilo2 tarea import threading import time #funcion que simula una tarea en un hilo def ( nombre , duracion ) : print ( f " El hilo { nombre } ha comenzado " ) time . ( duracion ) print ( f " El hilo { nombre } ha terminado " ) # Crear dos hilos que se ejecutarán en paralelo hilo1 = threading . Thread ( target = tarea , args = ( " Hilo 1 " , 2 ) ) # Toma 2 segundos hilo2 = threading . Thread ( target = tarea , args = ( " Hilo 2 " , 4 ) ) # Toma 2 segundos # Iniciar los hilos hilo1 . ( ) . start ( ) # Esperar a que ambos hilos terminen hilo1 . ( ) hilo2 . join ( ) print ( " Todos los hilos han terminado . " )