jfcmacro icon

EjemploHilo5.java

jfcmacro | PRO | 03/27/19 04:43:20 PM UTC | 0 ⭐ | 396 👁️ | Never ⏰ | []
Java |

780 B

|

None

|

0 👍

/

0 👎

class EjemploHilo5 implements Runnable {
 
    public void run() {
    System.out.println("Esto es otro hilo: " + Thread.currentThread());
    }
 
    public static void main(String []args) {
    ThreadGroup tg = new ThreadGroup("fumador");
    Thread eh3_1 = new Thread(tg, new EjemploHilo5(), "Ejemplo hilo 3 1");
    Thread eh3_2 = new Thread(tg, new EjemploHilo5(), "Ejemplo hilo 3 2");
 
    eh3_1.start();
    eh3_2.start();
    try {
        System.out.println("Activos: " + tg.activeCount());
        System.out.println("Esta vivo: " + eh3_1.isAlive());
        System.out.println("Estos un hilo " + Thread.currentThread());
        eh3_1.join();
        System.out.println("Esta vivo: " + eh3_1.isAlive());
        tg.list();
        System.out.println("Activos: " + tg.activeCount());
    }
    catch (InterruptedException ie) {
    }
    }
}

Comments