jfcmacro icon

EjemploHilo7.java

jfcmacro | PRO | 03/27/19 05:01:09 PM UTC | 0 ⭐ | 318 👁️ | Never ⏰ | []
Java |

590 B

|

None

|

0 👍

/

0 👎

class EjemploHilo7 implements Runnable {
 
    public EjemploHilo7() {
    }
 
    public void run() {
    Thread t = Thread.currentThread();
 
    while (true) {
        System.out.println("Esto es otro hilo: " + t);
        if (t.isInterrupted()) break;
    }
    System.out.println("Good bye, cruel world!");
    }
 
    public static void main(String []args) {
    ThreadGroup tg = new ThreadGroup("fumador");
    Thread eh7_1 = new Thread(tg, new EjemploHilo7(), "Ejemplo hilo 7 1");
 
    eh7_1.start();
    try {
 
        Thread.currentThread().sleep(2000);
        eh7_1.interrupt();
 
    }
    catch (InterruptedException ie) {
    }
    }
}

Comments