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