jfcmacro icon

EjemploHilo6.java

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

680 B

|

None

|

0 👍

/

0 👎

class EjemploHilo6 implements Runnable {
 
    private int priority;
 
    public EjemploHilo6(int priority) {
    this.priority = priority;
    }
    
    public void run() {
    Thread t = Thread.currentThread();
    t.setPriority(priority);
    for (int i = 0; i < 20; ++i) {
        System.out.println("Esto es otro hilo: " + t);
    }
    }
 
    public static void main(String []args) {
    ThreadGroup tg = new ThreadGroup("fumador");
    Thread eh6_1 = new Thread(tg, new EjemploHilo6(1), "Ejemplo hilo 6 1");
    Thread eh6_2 = new Thread(tg, new EjemploHilo6(10), "Ejemplo hilo 6 2");
 
    eh6_1.start();
    eh6_2.start();
    try {
 
        eh6_1.join();
        eh6_2.join();
    }
    catch (InterruptedException ie) {
    }
    }
}

Comments