Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment