<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">public class Hilo extends Thread
{
    private int proceso;
    private int tiempoInactividad;
    
    public Hilo(int nombre)
    {
        proceso = nombre;
    }
    
    public void run()
    {
        try{
            while( true)
            {
                tiempoInactividad = 999 + ( int ) ( Math.random() * 3001 );
                System.err.println("hilo="+proceso+" nombre_interno=["+getName()+"] inactividad="+tiempoInactividad+" ms");
                sleep(tiempoInactividad);
                if( tiempoInactividad &gt;= 2000 &amp;&amp; tiempoInactividad &lt; 3000)
                    break;
            }            
        }
        catch(InterruptedException excepcion)
        {
            excepcion.printStackTrace();
            System.err.println(excepcion.getMessage());
        }
        System.err.println("hilo="+proceso+" nombre_interno=["+getName()+"] muerto");
    }    
}</pre></body></html>